Jump to content

atl_andy

Members
  • Posts

    141
  • Joined

  • Last visited

    Never

About atl_andy

  • Birthday 03/04/1973

Profile Information

  • Gender
    Not Telling

atl_andy's Achievements

Member

Member (2/5)

0

Reputation

  1. Something more manageable from a data perspective might be: date userid unique_calls total_calls call_type 20-DEC-2009 123456 5 7 incoming 20-DEC-2009 123456 2 5 outgoing You would then do any calculations when data is selected from the db.
  2. I went with FPDF...no licensing issues. It took a couple of hours to get everything working, starting from scratch and never using it before. That's just working out a basic table layout and integrating an email function. Didn't check out PDFLib before going with FPDF.
  3. Here's another option for using one table, that holds all transactions together. Have a master transaction number that auto increments, JOU0001, JOU0002, etc. along with the transaction ID. Then you have a sequence number table for each transaction type, Sales sequence, Invoice sequence, which would populate a FK field to each table. SAL0001 linked to JOU0001, INV0001 linked to JOU0002, SAL0002 linked to INV0003. I work on a ERP system that uses this type of model for journal entries. It's quite a bit more complex since it has an inventory function that writes to the GL as well. Your best bet for data integrity would be to use one large table, IMHO.
  4. There should be a green button near the bottom of your screen that says "SOLVED", or something...click it.
  5. You have syntax issues...try: $sql="INSERT INTO people (fname, lname, username, password, joined, email, level) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[user]',sha1('$_POST[pass]'),'$date','$_POST[email]','norm')"; $result = mysql_query($sql); $sqlcheck="SELECT * FROM people WHERE username = '$_POST[user]' OR email = '$_POST[email]'"; $result = mysql_query($sqlcheck); $numrows = mysql_num_rows($result); check these links for the correct usage of INSERT and SELECT statements http://us.php.net/mysql_num_rows for using mysql_num_rows and http://us.php.net/manual/en/function.mysql-query.php for SELECT and INSERT statements
  6. thanks teamatomic, that worked <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link type="text/css" href="test.css" rel="stylesheet" /> </head> <body> <div id="img"> <img src="http://localhost/images/thumbs/tn.jpg" /> </div> </body> </html>
  7. I'm trying to figure out how Imagick works and, after searching Google, the only information I can find is a couple of tutorials. They don't get into the meat of the subject. I have been successful in reading a directory and writing a picture to a new directory. The issue I'm having is using the new picture after it is written to a directory. My simple example will create a thumbnail of a picture and display it on the screen. $dh = opendir('/var/www/images/'); while ($file = readdir($dh)) { if ($file != "." and $file != ".." and is_file($file)) { $img = new Imagick(); $img->readImage($file); if ($img) { $img->thumbnailImage(150,150, false); $img->writeImage('/var/www/images/thumbs/tn.jpg'); header("Content-type: image/jpg"); echo $img; } $img->destroy(); } } closedir($dh); But when I try to use the image, nothing displays: <img src="/var/www/images/tn.jpg" /> I'm not sure if it's a permissions issue, the new file is owned by the web server: -rw-r--r-- 1 www-data www-data 30895 2009-12-26 10:18 tn.jpg The file opens fine in GIMP. Any suggestions? My goal is to create an admin feature on a site so that images are uploaded and resized to thumbnails and displayed in a gallery. I would like to avoid using a 3rd party script so I can learn something new other than tweaking someone else's script.
  8. That was the problem. I figured the output would be in the cwd...guess not. It worked after I put in the absolute path.
  9. ok, I checked the permission on the path to the file and it was ok. As long as the file exists, it will be emailed. If the file doesn't exist, it won't be created. The issue has to be the PDF creation portion of the script. I'm stuck on how to proceed.
  10. The file is created and saved in /var/www. Required files, connection, and select query: #!/usr/bin/php -q -c <?php require('/var/www/html/admin/cdr/lib/fpdf.php'); require_once('/var/www/reports/Swift-4.0.5/lib/swift_required.php'); $conn=mysql_connect("localhost","user","pass"); mysql_select_db("asteriskcdrdb",$conn); if(!$conn) { echo "Cannot connect to db"; } // Select query $result=mysql_query("SELECT src,clid,dcontext,calldate FROM cdr WHERE dcontext='from-internal' AND calldate>=DATE_ADD(CURDATE(),INTERVAL -45 HOUR) AND calldate<=DATE_ADD(CURDATE(),INTERVAL -21 HOUR) ORDER BY src"); if(!$result) { echo "Cannot process query"; } PDF creation, save and email using Swift mailer class PDF extends FPDF { private $_yesterday1; // Page Header function Header() { // yesterday date $_yesterday1=date('m/d/Y',mktime(0,0,0,date("m"),date("d")-1,date("Y"))); // Arial bold 15 $this->SetFont('Arial','B',14); // Title $this->Cell(0,10,$_yesterday1,0,0,'C'); // Line Break $this->Ln(20); } } // Create a new PDF file $pdf = new PDF(); $pdf->AddPage(); // Field Name position $Y_Fields_Name_position = 20; // Table position, under Field Name position $Y_Table_Position = 26; // First create each field name // Gray color filling each Field Name box $pdf->SetFillColor(232,232,232); // Bold font for Field Name $pdf->SetFont('Arial','B',12); $pdf->SetY($Y_Fields_Name_position); $pdf->SetX(5); $pdf->Cell(45,6,'Sales Rep',1,0,'L',1); $pdf->SetX(50); $pdf->Cell(45,6,'Calls Made',1,0,'L',1); $pdf->Ln(); // Formulate call results while($row=mysql_fetch_object($result)) { if(preg_match("/Conor/",$row->clid) && preg_match("/2164/",$row->clid)) { $conor += 1; } if(preg_match("/Shon/",$row->clid) && preg_match("/7733/",$row->clid)) { $shon += 1; } // Show Conor; $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position); $pdf->SetX(5); $pdf->MultiCell(45,6,"Conor",1); $pdf->SetY($Y_Table_Position); $pdf->SetX(50); $pdf->MultiCell(45,6,$conor,1); $pdf->SetY($Y_Table_Position); // Show Shon $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position+6); $pdf->SetX(5); $pdf->MultiCell(45,6,"Shon",1); $pdf->SetY($Y_Table_Position+6); $pdf->SetX(50); $pdf->MultiCell(45,6,$shon,1); $pdf->SetY($Y_Table_Position+6); // yesterday date $yesterday=date('m/d/Y',mktime(0,0,0,date("m"),date("d")-1,date("Y"))); $pdf->Output("daily_report.pdf",'F'); // Create mail message $message = Swift_Message::newInstance() // Subject ->setSubject("Daily Call Report - " . $yesterday) // From address ->setFrom(array('email@email.com'=>'User')) // To address ->setTo(array('email@email.com'=>'User')) // Body ->setBody('Daily Call Report For ' . $yesterday) // Add attachment -> attach(Swift_Attachment::fromPath('/var/www/reports/daily_report.php')); // Create the transport $transport = Swift_MailTransport::newInstance(); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); // Send the message $numSent = $mailer->send($message); //printf("Sent %d messages\n", $numSent); //if ($mailer->send($message)) //{ echo "Sent\n"; } //else //{ echo "Failed\n"; }
  11. Hello, I have a PHP script that will create a PDF then email it as an attachment. Everything works great if I run the script manually from the command line. The PDF is created for the date range of the SQL query, and the email is sent to the recipients listed in the script. However, if I try to run the script in a cron job, only the email portion of the script will work; and that part will work only if the previous day's PDF is in the directory. Nothing will work if there is no file from the previous day ( I have tried to use unlink() to delete the file to prevent the previous day's email from being sent...unsuccessfully). Also, if the job runs on Tuesday and Wednesday, the PDF for Tuesday will be send each time. I'm baffled on which part of the system is not working and what to troubleshoot. I read, one a post somewhere, that to get cron to work with PHP the --enable-cgi flag might need to be set during compilation. This is running on an Asterisk server so there are no page visits that will allow the script to be run when a page is visited, or to use another web based cron-style application. I also checked the file permission and made the script executable. Cron job (I checked the logs and it runs without errors): 0 8 * * 1,2,3,4,5,6 /usr/bin/php -q /var/www/reports/reports.php Any help or insight would be appreciated. I can post code from the script if necessary, but I don't think that is the problem.
  12. Check out Swift mailer. It's an extremely simple-to-use PHP class. http://swiftmailer.org/
  13. I recently did some research on this, and here is what I use: 0 3 * * * 1,2,3,4,5,6 /usr/bin/php /var/www/test.php That will run every day at 3am. Change the 0 to a */5, and the 3 to a * to run it every 5 minutes. /usr/bin/php is the path to php and /var/www/test.php is the path to your file. Your paths may be different.
  14. I have a script running at 8am on a cron job. It uses Swift mailer to email a pdf document. If I run the script from the command line everything works great. But there are two issues when it is run using cron. The first issue is the file sent will not update to the current date, it just sends the previous day's pdf. The second issue was an attempt to get around the first. I used unlink to delete the file and touch to create it again, thinking that would eliminate the repeating file problem. To summarize, I need the script to get data from a mysql table that will be emailed in a pdf every morning via a cron job. The server is running CentOS 5.3 with LAMP. Here's the select statement: $result=mysql_query("SELECT src,clid,dcontext,calldate FROM cdr WHERE dcontext='from-internal' AND calldate>=DATE_ADD(CURDATE(),INTERVAL -21 HOUR) AND calldate<=DATE_ADD(CURDATE(),INTERVAL +3 HOUR) ORDER BY src"); Here's the cron job: 0 8 * * * 1,2,3,4,5,6 /usr/bin/php /var/www/reports/report.php Here's the mail portion on the script: // yesterday date $yesterday=date('m/d/Y',mktime(0,0,0,date("m"),date("d")-1,date("Y"))); $pdf->Output("daily_report.pdf",'F'); // Create mail message $message = Swift_Message::newInstance() // Subject ->setSubject("Daily Call Report - " . $yesterday) // From address ->setFrom(array('agriggs@impulsetech.us'=>'Andy Griggs')) // To address ->setTo(array('agriggs@impulsetech.us'=>'Andy Griggs')) // Body ->setBody('Daily Call Report For ' . $yesterday) // Add attachment -> attach(Swift_Attachment::fromPath('/var/www/reports/test.php')); // Create the transport $transport = Swift_MailTransport::newInstance(); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); // Send the message $numSent = $mailer->send($message); // Delete the daily report file after emailing it unlink('daily_report.pdf'); // Create file so the cron job will work touch("/var/www/reports/daily_report.pdf"); Any help is greatly appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.