From: <tim...@us...> - 2010-01-06 13:27:54
|
Revision: 3275 http://web-erp.svn.sourceforge.net/web-erp/?rev=3275&view=rev Author: tim_schofield Date: 2010-01-06 12:19:52 +0000 (Wed, 06 Jan 2010) Log Message: ----------- Enable each company to have their own layouts for orders/invoices etc Modified Paths: -------------- trunk/PO_PDFPurchOrder.php trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml trunk/doc/Change.log.html trunk/includes/PO_PDFOrderPageHeader.inc trunk/index.php Added Paths: ----------- trunk/FormDesigner.php Added: trunk/FormDesigner.php =================================================================== --- trunk/FormDesigner.php (rev 0) +++ trunk/FormDesigner.php 2010-01-06 12:19:52 UTC (rev 3275) @@ -0,0 +1,237 @@ +<?php +/* $Id$ */ +$PageSecurity = 14; +include('includes/session.inc'); +$title = _('Form Designer'); +include('includes/header.inc'); +function FontSizes() { + return array(6, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24); //Possible font sizes +} +function SimpleTextLine($key) { + /* Displays a table row containing the attributes for a + * line of text of type `SimpleText` and the values + * given in the object $key + */ + $FontSizes=FontSizes(); + echo '<td class=number>'._('Font Size').' = '.'</td><td><select name="'.$key['id'].'FontSize">'; + foreach ($FontSizes as $FontSize) { + if ($FontSize==$key->FontSize) { + echo '<option selected value="'.$FontSize.'">'.$FontSize.'</option>'; + } else { + echo '<option value="'.$FontSize.'">'.$FontSize.'</option>'; + } + } + echo '</select></td>'; + /* Display the X co-ordinate (mm from the left hand side of page) */ + echo '<td class=number>'._('x').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'x" size=4 maxlength=4 value="'.$key->x.'"></td>'; + /* Display the Y co-ordinate (mm from the top of the page) */ + echo '<td class=number>'._('y').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'y" size=4 maxlength=4 value="'.$key->y.'"></td>'; +} +function MultiTextLine($key) { + /* Displays a table row containing the attributes for a + * line of text of type `MultiLineText` and the values + * given in the object $key + */ + $FontSizes=FontSizes(); + echo '<td class=number>'._('Font Size').' = '.'</td><td><select name="'.$key['id'].'FontSize">'; + foreach ($FontSizes as $FontSize) { + if ($FontSize==$key->FontSize) { + echo '<option selected value="'.$FontSize.'">'.$FontSize.'</option>'; + } else { + echo '<option value="'.$FontSize.'">'.$FontSize.'</option>'; + } + } + echo '</select></td>'; + /* Display the length of the field in mm */ + echo '<td class=number>'._('Length').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'Length" size=4 maxlength=4 value="'.$key->Length.'"></td></tr><tr>'; + /* Display the X co-ordinate (mm from the left hand side of page) */ + echo '<td class=number>'._('x').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'x" size=4 maxlength=4 value="'.$key->x.'"></td>'; + /* Display the Y co-ordinate (mm from the top of the page) */ + echo '<td class=number>'._('y').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'y" size=4 maxlength=4 value="'.$key->y.'"></td>'; +} +function DataTextLine($key) { + /* Displays a table row containing the attributes for a + * line of text of type `DataText` and the values + * given in the object $key + */ + $FontSizes=FontSizes(); + echo '<td class=number>'._('Font Size').' = '.'</td><td><select name="'.$key['id'].'FontSize">'; + foreach ($FontSizes as $FontSize) { + if ($FontSize==$key->FontSize) { + echo '<option selected value="'.$FontSize.'">'.$FontSize.'</option>'; + } else { + echo '<option value="'.$FontSize.'">'.$FontSize.'</option>'; + } + } + echo '</select></td>'; + /* Display the length of the field in mm */ + echo '<td class=number>'._('Length').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'Length" size=4 maxlength=4 value="'.$key->Length.'"></td>'; + /* Display the X co-ordinate (mm from the left hand side of page) */ + echo '<td class=number>'._('x').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'x" size=4 maxlength=4 value="'.$key->x.'"></td>'; +} +/* If the user has chosen to either preview the form, or + * save it then we first have to get the POST values into a + * simplexml object and then save the file as either a + * temporary file, or into the main code + */ +if (isset($_POST['preview']) or isset($_POST['save'])) { + /*First create a simple xml object from the main file */ + $FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/'.$_POST['FormName']); + $FormDesign['name']=$_POST['formname']; + $FormDesign->PaperSize=$_POST['PaperSize']; + $FormDesign->LineHeight=$_POST['LineHeight']; + /*Iterate through the object filling in the values from + * the POST variables */ + foreach ($FormDesign as $key) { + foreach ($key as $subkey=>$value) { + if ($key['type']=='ElementArray') { + foreach ($value as $subsubkey=>$subvalue) { + $value->$subsubkey = $_POST[$value['id'].$subsubkey]; + } + } else { + $key->$subkey = $_POST[$key['id'].$subkey]; + } + } + } + /* If we are just previewing the form then + * save it to the temporary directory and call the + * PDF creating script */ + if (isset($_POST['preview'])) { + $FormDesign->asXML(sys_get_temp_dir().'/'.$_POST['FormName']); + echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/PO_PDFPurchOrder.php?' . SID .'OrderNo=Preview">'; + } else { + /* otherwise check that the web server has write premissions on the companies + * directory and save the xml file to the correct directory */ + if (is_writable($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/'.$_POST['FormName'])) { + $FormDesign->asXML($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/'.$_POST['FormName']); + } else { + prnMsg( _('The web server does not have write permissions on the file ').'<br />'.$PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/'.$_POST['FormName']. + '<br />'._('Your changes cannot be saved').'<br />'._('See your system administrator to correct this problem'), 'error'); + } + } +} +/* If no form has been selected to edit, then offer a + * drop down list of possible forms */ +if (empty($_POST['FormName'])) { + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/maintenance.png" title="' . _('Search') . '" alt="">' . ' ' . $title.'<br>'; + echo '<form method="post" id="ChooseForm" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '">'; + echo '<table><tr>'; + echo '<td>'. _('Select the form to edit') .'</td><td><select name="FormName">'; + /* Iterate throght the appropriate companies FormDesigns/ directory + * and extract the form name from each of the xml files found */ + if ($handle = opendir($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/')) { + while (false !== ($file = readdir($handle))) { + if ($file[0]!='.') { + $FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/'.$file); + echo '<option value="'.$file.'">'.$FormDesign['name'].'</option>'; + } + } + closedir($handle); + } + echo '</select></td></tr></table>'; + echo '<br /><div class="centre"><input tabindex="6" type="submit" name="submit" value="' . _('Edit Form Layout') . '" /></div>'; + echo '</form>'; + include('includes/footer.inc'); + exit; +} // End of if (empty($_POST['FormName'])) +/* If we are not previewing the form then load up the simplexml + * object from the main xml file */ +if (empty($_POST['preview'])) { + $FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/'.$_POST['FormName']); +} +echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/reports.png" title="' . _('Form Design') . '" alt="">' . ' ' . _('Form Design').'<br />'. $FormDesign['name'] . ''; +echo '<div class="page_help_text">' . _('Enter the changes that you want in the form layout below.') .'<br /> '. _('All measurements are in millimetres') . '.</div><br>'; +$Papers=array('A4_Landscape', 'A4_Portrait', 'A3_Lanscape', 'A3_Portrait'); // Possible paper sizes/orientations +echo '<form method="post" id="Form" action="' . $_SERVER['PHP_SELF'] . '?' . SID . '">'; +echo '<input name=FormName type=hidden value="'.$_POST['FormName'].'">'; +echo '<table width=85% border=1>'; //Start of outer table +echo '<tr><th width=33%>'._('Form Name').'<input type="text" name="formname" value="'.$FormDesign['name'].'"></th>'; +/* Select the paper size/orientation */ +echo '<th width=33%>'._('Paper Size').'<select name="PaperSize">'; +foreach ($Papers as $Paper) { + if ($Paper==$FormDesign->PaperSize) { + echo '<option selected value="'.$Paper.'">'.$Paper.'</option>'; + } else { + echo '<option value="'.$Paper.'">'.$Paper.'</option>'; + } +} +echo '</select></th>'; +/* and the standard line height for the form */ +echo '<th width=33%>'._('Line Height').'<input type="text" class="number" name="LineHeight" size=3 maxlength=3 value="'.$FormDesign->LineHeight.'"></th></tr><tr>'; +$counter=1; // Count how many sub tables are in the row +foreach ($FormDesign as $key) { + switch ($key['type']) { + case 'image': + echo '<td colspan=1 valign=top><table width=100% border=1><tr><th colspan=8>'.$key['name'].'</th></tr>'; + echo '<td class=number>'._('x').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'x" size=4 maxlength=4 value="'.$key->x.'"></td>'; + echo '<td class=number>'._('y').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'y" size=4 maxlength=4 value="'.$key->y.'"></td>'; + echo '<td class=number>'._('Width').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'width" size=4 maxlength=4 value="'.$key->width.'"></td>'; + echo '<td class=number>'._('Height').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'height" size=4 maxlength=4 value="'.$key->height.'"></td>'; + echo '</table></td>'; + $counter=$counter+1; + break; + case 'SimpleText': + echo '<td colspan=1 valign=top><table width=100% border=1><tr><th colspan=6>'.$key['name'].'</th></tr>'; + SimpleTextLine($key); + echo '</table></td>'; + $counter=$counter+1; + break; + case 'MultiLineText': + echo '<td colspan=1 valign=top><table width=100% border=1><tr><th colspan=4>'.$key['name'].'</th></tr>'; + MultiTextLine($key); + echo '</table></td>'; + $counter=$counter+1; + break; + case 'ElementArray': + echo '<td colspan=1 valign=top><table width=100% border=1><tr><th colspan=7>'.$key['name'].'</th></tr>'; + foreach ($key as $subkey) { + if ($subkey['type']=='SimpleText') { + echo '<tr>'; + echo '<td>'.$subkey['name'].'</td>'; + SimpleTextLine($subkey); + echo '</tr>'; + } else { + echo '<tr>'; + if ($subkey['type']=='DataText') { + echo '<td>'.$subkey['name'].'</td>'; + DataTextLine($subkey); + } elseif ($subkey['type']=='StartLine') { + echo '<td colspan=3>'.$subkey['name'].' = '.'</td><td><input type="text" class="number" name="StartLine" size=4 maxlength=4 value="'.$key->y.'"></td>'; + } + echo '</tr>'; + } + } + echo '</table></td>'; + $counter=$counter+1; + break; + case 'CurvedRectangle': + echo '<td colspan=1 valign=top><table width=100% border=1><tr><th colspan=6>'.$key['name'].'</th></tr>'; + echo '<td class=number>'._('x').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'x" size=4 maxlength=4 value="'.$key->x.'"></td>'; + echo '<td class=number>'._('y').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'y" size=4 maxlength=4 value="'.$key->y.'"></td>'; + echo '<td class=number>'._('Width').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'width" size=4 maxlength=4 value="'.$key->width.'"></td></tr><tr>'; + echo '<td class=number>'._('Height').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'height" size=4 maxlength=4 value="'.$key->height.'"></td>'; + echo '<td class=number>'._('Radius').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'radius" size=3 maxlength=3 value="'.$key->radius.'"></td>'; + echo '</table></td>'; + $counter=$counter+1; + break; + case 'Rectangle': + echo '<td colspan=1 valign=top><table width=100% border=1><tr><th colspan=6>'.$key['name'].'</th></tr>'; + echo '<td class=number>'._('x').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'x" size=4 maxlength=4 value="'.$key->x.'"></td>'; + echo '<td class=number>'._('y').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'y" size=4 maxlength=4 value="'.$key->y.'"></td></tr><tr>'; + echo '<td class=number>'._('Width').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'width" size=4 maxlength=4 value="'.$key->width.'"></td>'; + echo '<td class=number>'._('Height').' = '.'</td><td><input type="text" class="number" name="'.$key['id'].'height" size=4 maxlength=4 value="'.$key->height.'"></td>'; + echo '</table></td>'; + $counter=$counter+1; + break; + } + if ($counter==4) { // If the row is full start a new one + $counter=1; + echo '</tr><tr>'; + } +} +echo '</tr></table>'; //End of outer table +echo '<br /><div class="centre"><input tabindex="6" type="submit" name="preview" value="' . _('Preview the Form Layout') . '" /></div>'; +echo '<br /><div class="centre"><input tabindex="6" type="submit" name="save" value="' . _('Save the Form Layout') . '" /></div>'; +echo '</form>'; +include('includes/footer.inc'); +?> \ No newline at end of file Property changes on: trunk/FormDesigner.php ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/PO_PDFPurchOrder.php =================================================================== --- trunk/PO_PDFPurchOrder.php 2010-01-06 09:35:10 UTC (rev 3274) +++ trunk/PO_PDFPurchOrder.php 2010-01-06 12:19:52 UTC (rev 3275) @@ -1,48 +1,48 @@ <?php - /* $Id$*/ - /* $Revision: 1.30 $ */ - $PageSecurity = 2; include('includes/session.inc'); include('includes/SQL_CommonFunctions.inc'); - include('includes/DefinePOClass.php'); - if(!isset($_GET['OrderNo']) && !isset($_POST['OrderNo'])){ - $title = _('Select a Purchase Order'); - include('includes/header.inc'); - echo '<div class="centre"><br><br><br>'; - prnMsg( _('Select a Purchase Order Number to Print before calling this page') , 'error'); - echo '<br><br><br><table class="table_index"> + $title = _('Select a Purchase Order'); + include('includes/header.inc'); + echo '<div class="centre"><br><br><br>'; + prnMsg( _('Select a Purchase Order Number to Print before calling this page') , 'error'); + echo '<br><br><br><table class="table_index"> <tr><td class="menu_group_item"> - <li><a href="'. $rootpath . '/PO_SelectOSPurchOrder.php?'.SID .'">' . _('Outstanding Purchase Orders') . '</a></li> - <li><a href="'. $rootpath . '/PO_SelectPurchOrder.php?'. SID .'">' . _('Purchase Order Inquiry') . '</a></li> - </td></tr></table></div><br><br><br>'; - include('includes/footer.inc'); - exit(); + <li><a href="'. $rootpath . '/PO_SelectOSPurchOrder.php?'.SID .'">' . _('Outstanding Purchase Orders') . '</a></li> + <li><a href="'. $rootpath . '/PO_SelectPurchOrder.php?'. SID .'">' . _('Purchase Order Inquiry') . '</a></li> + </td></tr></table></div><br><br><br>'; + include('includes/footer.inc'); + exit(); echo '<div class="centre"><br><br><br>' . _('This page must be called with a purchase order number to print'); echo '<br><a href="'. $rootpath . '/index.php?' . SID . '">' . _('Back to the menu') . '</a></div>'; exit; } - if (isset($_GET['OrderNo'])){ $OrderNo = $_GET['OrderNo']; } elseif (isset($_POST['OrderNo'])){ $OrderNo = $_POST['OrderNo']; } - $title = _('Print Purchase Order Number').' '. $OrderNo; - -$sql='SELECT status +/* If we are not previewing the order then find + * the order status */ +if ($OrderNo != 'Preview') { + $sql='SELECT status FROM purchorders WHERE orderno='.$OrderNo; -$result=DB_query($sql, $db); -$myrow=DB_fetch_array($result); -$OrderStatus=$myrow['status']; - + $result=DB_query($sql, $db); + $myrow=DB_fetch_array($result); + $OrderStatus=$myrow['status']; +} else { + /* otherwise set it to Printed */ + $_POST['ShowAmounts']='Yes'; + $OrderStatus = _('Printed'); + $MakePDFThenDisplayIt = True; +} if ($OrderStatus != PurchOrder::STATUS_AUTHORISED and $OrderStatus != PurchOrder::STATUS_PRINTED) { include('includes/header.inc'); prnMsg( _('Purchase orders can only be printed once they have been authorised') . '. ' . @@ -50,22 +50,23 @@ include('includes/footer.inc'); exit; } - $ViewingOnly = 0; if (isset($_GET['ViewingOnly']) && $_GET['ViewingOnly']!='') { $ViewingOnly = $_GET['ViewingOnly']; } elseif (isset($_POST['ViewingOnly']) && $_POST['ViewingOnly']!='') { $ViewingOnly = $_POST['ViewingOnly']; } - - +/* If we are previewing the order then we dont + * want to email it */ +if ($OrderNo != 'Preview') { + $_POST['PrintOrEmail']='Print'; +} if (isset($_POST['DoIt']) AND ($_POST['PrintOrEmail']=='Print' || $ViewingOnly==1) ){ $MakePDFThenDisplayIt = True; } elseif (isset($_POST['DoIt']) AND $_POST['PrintOrEmail']=='Email' AND strlen($_POST['EmailTo'])>6){ $MakePDFThenEmailIt = True; } - -if (isset($OrderNo) && $OrderNo != "" && $OrderNo > 0){ +if (isset($OrderNo) && $OrderNo != "" && $OrderNo > 0 && $OrderNo != 'Preview'){ //Check this up front. Note that the myrow recordset is carried into the actual make pdf section /*retrieve the order details from the database to print */ $ErrMsg = _('There was a problem retrieving the purchase order header details for Order Number'). ' ' . $OrderNo . @@ -96,69 +97,90 @@ ON purchorders.supplierno = suppliers.supplierid WHERE purchorders.orderno=" . $OrderNo; $result=DB_query($sql,$db, $ErrMsg); - - if (DB_num_rows($result)==0){ /*There is ony one order header returned */ - + if (DB_num_rows($result)==0){ /*There is no order header returned */ $title = _('Print Purchase Order Error'); include('includes/header.inc'); echo '<div class="centre"><br><br><br>'; prnMsg( _('Unable to Locate Purchase Order Number') . ' : ' . $OrderNo . ' ', 'error'); echo '<br><br><br><table class="table_index"> <tr><td class="menu_group_item"> - <li><a href="'. $rootpath . '/PO_SelectOSPurchOrder.php?'.SID .'">' . _('Outstanding Purchase Orders') . '</a></li> - <li><a href="'. $rootpath . '/PO_SelectPurchOrder.php?'. SID .'">' . _('Purchase Order Inquiry') . '</a></li> - </td></tr></table></div><br><br><br>'; + <li><a href="'. $rootpath . '/PO_SelectOSPurchOrder.php?'.SID .'">' . _('Outstanding Purchase Orders') . '</a></li> + <li><a href="'. $rootpath . '/PO_SelectPurchOrder.php?'. SID .'">' . _('Purchase Order Inquiry') . '</a></li> + </td></tr></table></div><br><br><br>'; include('includes/footer.inc'); exit(); - } elseif (DB_num_rows($result)==1){ /*There is only one order header returned */ - - $POHeader = DB_fetch_array($result); - if ($ViewingOnly==0) { - if ($POHeader['allowprint']==0){ - $title = _('Purchase Order Already Printed'); - include('includes/header.inc'); - echo '<p>'; - prnMsg( _('Purchase Order Number').' ' . $OrderNo . ' '. - _('has previously been printed') . '. ' . _('It was printed on'). ' ' . + $POHeader = DB_fetch_array($result); + if ($ViewingOnly==0) { + if ($POHeader['allowprint']==0){ + $title = _('Purchase Order Already Printed'); + include('includes/header.inc'); + echo '<p>'; + prnMsg( _('Purchase Order Number').' ' . $OrderNo . ' '. + _('has previously been printed') . '. ' . _('It was printed on'). ' ' . ConvertSQLDate($POHeader['dateprinted']) . '<br>'. - _('To re-print the order it must be modified to allow a reprint'). '<br>'. - _('This check is there to ensure that duplicate purchase orders are not sent to the supplier resulting in several deliveries of the same supplies'), 'warn'); - echo '<br><table class="table_index"> - <tr><td class="menu_group_item"> - <LI><a href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . 'OrderNo=' . $OrderNo . '&ViewingOnly=1">'. + _('To re-print the order it must be modified to allow a reprint'). '<br>'. + _('This check is there to ensure that duplicate purchase orders are not sent to the supplier resulting in several deliveries of the same supplies'), 'warn'); + echo '<br><table class="table_index"> + <tr><td class="menu_group_item"> + <li><a href="' . $rootpath . '/PO_PDFPurchOrder.php?' . SID . 'OrderNo=' . $OrderNo . '&ViewingOnly=1">'. _('Print This Order as a Copy'). '</a> - <LI><a href="' . $rootpath . '/PO_Header.php?' . SID . 'ModifyOrderNumber=' . $OrderNo . '">'. + <li><a href="' . $rootpath . '/PO_Header.php?' . SID . 'ModifyOrderNumber=' . $OrderNo . '">'. _('Modify the order to allow a real reprint'). '</a>' . - '<LI><a href="'. $rootpath .'/PO_SelectPurchOrder.php?' . SID . '">'. + '<li><a href="'. $rootpath .'/PO_SelectPurchOrder.php?' . SID . '">'. _('Select another order'). '</a>'. - '<LI><a href="' . $rootpath . '/index.php?' . SID . '">'. _('Back to the menu').'</a>'; - echo '</BODY></HTML>'; - include('includes/footer.inc'); - exit; - }//AllowedToPrint - }//not ViewingOnly + '<li><a href="' . $rootpath . '/index.php?' . SID . '">'. _('Back to the menu').'</a>'; + include('includes/footer.inc'); + exit; + }//AllowedToPrint + }//not ViewingOnly }// 1 valid record }//if there is a valid order number - +else if ($OrderNo=='Preview') {// We are previewing the order +/* Fill the order header details with dummy data */ + $POHeader['supplierno']=str_pad('',10,'x'); + $POHeader['suppname']=str_pad('',40,'x'); + $POHeader['address1']=str_pad('',40,'x'); + $POHeader['address2']=str_pad('',40,'x'); + $POHeader['address3']=str_pad('',40,'x'); + $POHeader['address4']=str_pad('',30,'x'); + $POHeader['comments']=str_pad('',50,'x'); + $POHeader['orddate']='1900-01-01'; + $POHeader['rate']='0.0000'; + $POHeader['dateprinted']='1900-01-01'; + $POHeader['deladd1']=str_pad('',40,'x'); + $POHeader['deladd2']=str_pad('',40,'x'); + $POHeader['deladd3']=str_pad('',40,'x'); + $POHeader['deladd4']=str_pad('',40,'x'); + $POHeader['deladd5']=str_pad('',20,'x'); + $POHeader['deladd6']=str_pad('',15,'x'); + $POHeader['allowprint']=1; + $POHeader['requisitionno']=str_pad('',15,'x'); + $POHeader['initiator']=str_pad('',50,'x'); + $POHeader['paymentterms']=str_pad('',15,'x'); + $POHeader['currcode']='XXX'; +} // end of If we are previewing the order +/* Load the relevant xml file */ if (isset($MakePDFThenDisplayIt) or isset($MakePDFThenEmailIt)) { - $FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/PurchaseOrder.xml'); - + if ($OrderNo=='Preview') { + $FormDesign = simplexml_load_file(sys_get_temp_dir().'/PurchaseOrder.xml'); + } else { + $FormDesign = simplexml_load_file($PathPrefix.'companies/'.$_SESSION['DatabaseName'].'/FormDesigns/PurchaseOrder.xml'); + } +// Set the paper size/orintation $PaperSize = $FormDesign->PaperSize; - include('includes/PDFStarter.php'); $pdf->addInfo('Title', _('Purchase Order') ); $pdf->addInfo('Subject', _('Purchase Order Number' ) . ' ' . $OrderNo); $line_height = $FormDesign->LineHeight; $PageNumber = 1; - /* Then there's an order to print and its not been printed already (or its been flagged for reprinting) Now ... Has it got any line items */ - - $ErrMsg = _('There was a problem retrieving the line details for order number') . ' ' . $OrderNo . ' ' . + if ($OrderNo !='Preview') { // It is a real order + $ErrMsg = _('There was a problem retrieving the line details for order number') . ' ' . $OrderNo . ' ' . _('from the database'); - $sql = "SELECT itemcode, - deliverydate, + $sql = "SELECT itemcode, + deliverydate, itemdescription, unitprice, unitname as units, @@ -169,19 +191,25 @@ LEFT JOIN unitsofmeasure ON purchorderdetails.uom=unitsofmeasure.unitid WHERE orderno =" . $OrderNo; - $result=DB_query($sql,$db); - - if (DB_num_rows($result)>0){ - /*Yes there are line items to start the ball rolling with a page header */ - + $result=DB_query($sql,$db); + } + if ($OrderNo=='Preview' or DB_num_rows($result)>0){ + /*Yes there are line items to start the ball rolling with a page header */ include('includes/PO_PDFOrderPageHeader.inc'); - $YPos=$Page_Height - $FormDesign->Data->y; - $OrderTotal = 0; - - while ($POLine=DB_fetch_array($result)){ - + while ((isset($OrderNo) and $OrderNo=='Preview') or (isset($result) and $POLine=DB_fetch_array($result))) { + /* If we are previewing the order then fill the + * order line with dummy data */ + if ($OrderNo=='Preview') { + $POLine['itemcode']=str_pad('',10,'x'); + $POLine['deliverydate']='1900-01-01'; + $POLine['itemdescription']=str_pad('',50,'x'); + $POLine['unitprice']=9999.99; + $POLine['units']=str_pad('',4,'x'); + $POLine['quantityord']=999.99; + $POLine['decimalplaces']=2; + } $DisplayQty = number_format($POLine['quantityord'],$POLine['decimalplaces']); if ($_POST['ShowAmounts']=='Yes'){ $DisplayPrice = number_format($POLine['unitprice'],2); @@ -194,107 +222,97 @@ } else { $DisplayLineTotal = "----"; } - - //check the supplier code from code item - $sqlsupp = "SELECT supplierdescription - FROM purchdata - WHERE stockid='" . $POLine['itemcode'] . "' - AND supplierno ='" . $POHeader['supplierno'] . "' - AND price='".$POLine['unitprice']."'"; - - $SuppResult = DB_query($sqlsupp,$db); - $SuppDescRow = DB_fetch_row($SuppResult); + /* Dont search for supplier data if it is a preview */ + if ($OrderNo !='Preview') { + //check the supplier code from code item + $sqlsupp = "SELECT supplierdescription + FROM purchdata + WHERE stockid='" . $POLine['itemcode'] . "' + AND supplierno ='" . $POHeader['supplierno'] . "' + AND price='".$POLine['unitprice']."'"; + $SuppResult = DB_query($sqlsupp,$db); + $SuppDescRow = DB_fetch_row($SuppResult); + } else { + $SuppDescRow[0]=''; + } if($SuppDescRow[0]==""){ $Desc=$POLine['itemdescription']; }else{ $Desc="".$SuppDescRow['0']." - ".$POLine['itemdescription'].""; } $OrderTotal += ($POLine['unitprice']*$POLine['quantityord']); - - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x,$YPos,$FormDesign->Data->Column1->length,$FormDesign->Data->Column1->FontSize,$POLine['itemcode'], 'left'); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x,$YPos,$FormDesign->Data->Column2->length,$FormDesign->Data->Column2->FontSize,$Desc, 'left'); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x,$YPos,$FormDesign->Data->Column3->length,$FormDesign->Data->Column3->FontSize,$DisplayQty, 'left'); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x,$YPos,$FormDesign->Data->Column4->length,$FormDesign->Data->Column4->FontSize,$POLine['units'], 'left'); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x,$YPos,$FormDesign->Data->Column5->length,$FormDesign->Data->Column5->FontSize,$DisplayDelDate, 'left'); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column6->x,$YPos,$FormDesign->Data->Column6->length,$FormDesign->Data->Column6->FontSize,$DisplayPrice, 'right'); - $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column7->x,$YPos,$FormDesign->Data->Column7->length,$FormDesign->Data->Column7->FontSize,$DisplayLineTotal, 'right'); - + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x,$YPos,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize,$POLine['itemcode'], 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x,$YPos,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize,$Desc, 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x,$YPos,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize,$DisplayQty, 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column4->x,$YPos,$FormDesign->Data->Column4->Length,$FormDesign->Data->Column4->FontSize,$POLine['units'], 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column5->x,$YPos,$FormDesign->Data->Column5->Length,$FormDesign->Data->Column5->FontSize,$DisplayDelDate, 'left'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column6->x,$YPos,$FormDesign->Data->Column6->Length,$FormDesign->Data->Column6->FontSize,$DisplayPrice, 'right'); + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column7->x,$YPos,$FormDesign->Data->Column7->Length,$FormDesign->Data->Column7->FontSize,$DisplayLineTotal, 'right'); if (strlen($LeftOvers)>1){ $LeftOvers = $pdf->addTextWrap($Left_Margin+1+94,$YPos-$line_height,270,$FontSize,$LeftOvers, 'left'); $YPos-=$line_height; } - if ($YPos-$line_height <= $Bottom_Margin){ - /* We reached the end of the page so finsih off the page and start a newy */ + /* We reached the end of the page so finsih off the page and start a newy */ $PageNumber++; include ('includes/PO_PDFOrderPageHeader.inc'); } //end if need a new page headed up - /*increment a line down for the next line item */ $YPos -= $line_height; - + /* If we are previewing we want to stop showing order + * lines after the first one */ + if ($OrderNo=='Preview') { +// unlink(sys_get_temp_dir().'/PurchaseOrder.xml'); + unset($OrderNo); + } } //end while there are line items to print out - if ($YPos-$line_height <= $Bottom_Margin){ // need to ensure space for totals - $PageNumber++; + $PageNumber++; include ('includes/PO_PDFOrderPageHeader.inc'); } //end if need a new page headed up - - if ($_POST['ShowAmounts']=='Yes'){ $DisplayOrderTotal = number_format($OrderTotal,2); } else { $DisplayOrderTotal = "----"; } - $YPos = $Bottom_Margin + $line_height; $pdf->addText($FormDesign->OrderTotalCaption->x,$Page_Height - $FormDesign->OrderTotalCaption->y, $FormDesign->OrderTotalCaption->FontSize, _('Order Total - excl tax'). ' ' . $POHeader['currcode']); - $LeftOvers = $pdf->addTextWrap($FormDesign->OrderTotal->x,$Page_Height - $FormDesign->OrderTotal->y,$Page_Height - $FormDesign->OrderTotal->length,$FormDesign->OrderTotal->FontSize,$DisplayOrderTotal, 'right'); - + $LeftOvers = $pdf->addTextWrap($FormDesign->OrderTotal->x,$Page_Height - $FormDesign->OrderTotal->y,$FormDesign->OrderTotal->Length,$FormDesign->OrderTotal->FontSize,$DisplayOrderTotal, 'right'); } /*end if there are order details to show on the order*/ - //} /* end of check to see that there was an order selected to print */ - - //failed var to allow us to print if the email fails. - $failed = false; - if ($MakePDFThenDisplayIt){ - - $pdf->OutputD($_SESSION['DatabaseName'] . '_PurchaseOrder_' . date('Y-m-d') . '.pdf');//UldisN - $pdf->__destruct(); //UldisN - - } else { /* must be MakingPDF to email it */ - - /* UldisN - $pdfcode = $pdf->output(); - $fp = fopen( $_SESSION['reports_dir'] . '/PurchOrder.pdf','wb'); - fwrite ($fp, $pdfcode); - fclose ($fp); - */ - - $PdfFileName = $_SESSION['DatabaseName'] . '_PurchaseOrder_' . date('Y-m-d') . '.pdf'; - $ReportsDirName = $_SESSION['reports_dir']; - $pdf->Output($ReportsDirName . '/' . $PdfFileName,'F');//UldisN - $pdf->__destruct(); //UldisN - - include('includes/htmlMimeMail.php'); - - $mail = new htmlMimeMail(); - $attachment = $mail->getFile($ReportsDirName . '/' . $PdfFileName); - $mail->setText( _('Please find herewith our purchase order number').' ' . $OrderNo); - $mail->setSubject( _('Purchase Order Number').' ' . $OrderNo); - $mail->addAttachment($attachment, $PdfFileName, 'application/pdf'); - $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] .">"); - $result = $mail->send(array($_POST['EmailTo'])); - if ($result==1){ - $failed = false; - echo '<p>'; - prnMsg( _('Purchase Order'). ' ' . $OrderNo.' ' . _('has been emailed to') .' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success'); - } else { - $failed = true; - echo '<p>'; - prnMsg( _('Emailing Purchase order'). ' ' . $OrderNo.' ' . _('to') .' ' . $_POST['EmailTo'] . ' ' . _('failed'), 'error'); - } - - } - + //} /* end of check to see that there was an order selected to print */ + //failed var to allow us to print if the email fails. + $failed = false; + if ($MakePDFThenDisplayIt){ + $pdf->OutputD($_SESSION['DatabaseName'] . '_PurchaseOrder_' . date('Y-m-d') . '.pdf');//UldisN + $pdf->__destruct(); //UldisN + } else { /* must be MakingPDF to email it */ + /* UldisN + $pdfcode = $pdf->output(); + $fp = fopen( $_SESSION['reports_dir'] . '/PurchOrder.pdf','wb'); + fwrite ($fp, $pdfcode); + fclose ($fp); + */ + $PdfFileName = $_SESSION['DatabaseName'] . '_PurchaseOrder_' . date('Y-m-d') . '.pdf'; + $ReportsDirName = $_SESSION['reports_dir']; + $pdf->Output($ReportsDirName . '/' . $PdfFileName,'F');//UldisN + $pdf->__destruct(); //UldisN + include('includes/htmlMimeMail.php'); + $mail = new htmlMimeMail(); + $attachment = $mail->getFile($ReportsDirName . '/' . $PdfFileName); + $mail->setText( _('Please find herewith our purchase order number').' ' . $OrderNo); + $mail->setSubject( _('Purchase Order Number').' ' . $OrderNo); + $mail->addAttachment($attachment, $PdfFileName, 'application/pdf'); + $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] .">"); + $result = $mail->send(array($_POST['EmailTo'])); + if ($result==1){ + $failed = false; + echo '<p>'; + prnMsg( _('Purchase Order'). ' ' . $OrderNo.' ' . _('has been emailed to') .' ' . $_POST['EmailTo'] . ' ' . _('as directed'), 'success'); + } else { + $failed = true; + echo '<p>'; + prnMsg( _('Emailing Purchase order'). ' ' . $OrderNo.' ' . _('to') .' ' . $_POST['EmailTo'] . ' ' . _('failed'), 'error'); + } + } if ($ViewingOnly==0 && !$failed) { $commentsql='SELECT initiator,stat_comment FROM purchorders WHERE orderno='.$OrderNo; $commentresult=DB_query($commentsql,$db); @@ -307,23 +325,20 @@ $StatusComment=$date.' - Printed by <a href="mailto:'.$emailrow['email'].'">'.$_SESSION['UserID']. '</a><br>'.$comment; $sql = " - UPDATE purchorders + UPDATE purchorders SET - allowprint = 0, + allowprint = 0, dateprinted = '" . Date('Y-m-d') . "', - status = '" . PurchOrder::STATUS_PRINTED . "', + status = '" . PurchOrder::STATUS_PRINTED . "', stat_comment = '" . $StatusComment . "' WHERE - purchorders.orderno = " . $OrderNo; + purchorders.orderno = " . $OrderNo; $result = DB_query($sql,$db); } - } /* There was enough info to either print or email the purchase order */ else { /*the user has just gone into the page need to ask the question whether to print the order or email it to the supplier */ - include ('includes/header.inc'); echo '<form action="' . $_SERVER['PHP_SELF'] . '?' . SID . '" method=post>'; - if ($ViewingOnly==1){ echo '<input type=hidden name="ViewingOnly" VALUE=1>'; } @@ -331,11 +346,9 @@ echo '<input type=hidden name="OrderNo" VALUE="'. $OrderNo. '">'; echo '<table><tr><td>'. _('Print or Email the Order'). '</td><td> <select name="PrintOrEmail">'; - if (!isset($_POST['PrintOrEmail'])){ $_POST['PrintOrEmail'] = 'Print'; } - if ($_POST['PrintOrEmail']=='Print'){ echo '<option selected VALUE="Print">'. _('Print'); echo '<option VALUE="Email">' . _('Email'); @@ -344,14 +357,11 @@ echo '<option selected VALUE="Email">'. _('Email'); } echo '</select></td></tr>'; - echo '<tr><td>'. _('Show Amounts on the Order'). '</td><td> <select name="ShowAmounts">'; - if (!isset($_POST['ShowAmounts'])){ $_POST['ShowAmounts'] = 'Yes'; } - if ($_POST['ShowAmounts']=='Yes'){ echo '<option selected VALUE="Yes">'. _('Yes'); echo '<option VALUE="No">' . _('No'); @@ -359,7 +369,6 @@ echo '<option VALUE="Yes">'. _('Yes'); echo '<option selected VALUE="No">'. _('No'); } - echo '</select></td></tr>'; if ($_POST['PrintOrEmail']=='Email'){ $ErrMsg = _('There was a problem retrieving the contact details for the supplier'); @@ -369,7 +378,6 @@ ON suppliercontacts.supplierid=purchorders.supplierno WHERE purchorders.orderno=$OrderNo"; $ContactsResult=DB_query($SQL,$db, $ErrMsg); - if (DB_num_rows($ContactsResult)>0){ echo '<tr><td>'. _('Email to') .':</td><td><select name="EmailTo">'; while ($ContactDetails = DB_fetch_array($ContactsResult)){ @@ -395,4 +403,4 @@ echo '</form>'; include('includes/footer.inc'); } -?> +?> \ No newline at end of file Modified: trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml =================================================================== --- trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml 2010-01-06 09:35:10 UTC (rev 3274) +++ trunk/companies/weberpdemo/FormDesigns/PurchaseOrder.xml 2010-01-06 12:19:52 UTC (rev 3275) @@ -1,273 +1,273 @@ -<?xml version="1.0" encoding="UTF-8" ?> +<?xml version="1.0" encoding="UTF-8"?> <form name="Purchase Order"> <PaperSize name="Paper size">A4_Landscape</PaperSize> - <LineHeight name "Line height">16</LineHeight> - <logo type="logo" name="Logo"> + <LineHeight name="Line height">16</LineHeight> + <logo type="image" name="Logo" id="Logo"> <x>0</x> <y>62</y> <width>0</width> <height>60</height> </logo> - <OrderNumber type="SimpleText" name="Order Number"> + <OrderNumber type="SimpleText" name="Order Number" id="OrderNumber"> <FontSize>15</FontSize> <x>391</x> <y>46</y> </OrderNumber> - <ViewingOnly type="SimpleText" name="Viewing only text"> + <ViewingOnly type="SimpleText" name="Viewing only warning text" id="ViewingOnly"> <FontSize>16</FontSize> <x>391</x> <y>62</y> </ViewingOnly> - <PageNumber type="SimpleText" name="Page number"> + <PageNumber type="SimpleText" name="Page number" id="PageNumber"> <FontSize>10</FontSize> <x>762</x> <y>70</y> </PageNumber> - <TaxAuthority type="SimpleText" name="Tax Authority"> + <TaxAuthority type="SimpleText" name="Tax Authority" id="TaxAuthority"> <FontSize>10</FontSize> <x>40</x> <y>106</y> </TaxAuthority> - <CompanyName type="SimpleText" name="Company name"> + <CompanyName type="SimpleText" name="Company name" id="CompanyName"> <FontSize>10</FontSize> <x>40</x> <y>122</y> </CompanyName> <CompanyAddress type="ElementArray" name="Company address"> - <Line1 type="SimpleText" name="Company address line 1"> + <Line1 type="SimpleText" name="Line 1" id="CompanyAddress1"> <FontSize>10</FontSize> <x>40</x> <y>132</y> </Line1> - <Line2 type="SimpleText" name="Company address line 2"> + <Line2 type="SimpleText" name="Line 2" id="CompanyAddress2"> <FontSize>10</FontSize> <x>40</x> <y>142</y> </Line2> - <Line3 type="SimpleText" name="Company address line 3"> + <Line3 type="SimpleText" name="Line 3" id="CompanyAddress3"> <FontSize>10</FontSize> <x>40</x> <y>152</y> </Line3> - <Line4 type="SimpleText" name="Company address line 4"> + <Line4 type="SimpleText" name="Line 4" id="CompanyAddress4"> <FontSize>10</FontSize> <x>40</x> <y>162</y> </Line4> - <Line5 type="SimpleText" name="Company address line 5"> + <Line5 type="SimpleText" name="Line 5" id="CompanyAddress5"> <FontSize>10</FontSize> <x>40</x> <y>172</y> </Line5> </CompanyAddress> - <CompanyPhone type="SimpleText" name="Company phone number"> + <CompanyPhone type="SimpleText" name="Company phone number" id="CompanyPhone"> <FontSize>10</FontSize> <x>40</x> <y>182</y> </CompanyPhone> - <CompanyFax type="SimpleText" name="Company fax number"> + <CompanyFax type="SimpleText" name="Company fax number" id="CompanyFax"> <FontSize>10</FontSize> <x>40</x> <y>192</y> </CompanyFax> - <CompanyEmail type="SimpleText" name="Company email address"> + <CompanyEmail type="SimpleText" name="Company email address" id="CompanyEmail"> <FontSize>10</FontSize> <x>40</x> <y>202</y> </CompanyEmail> <DeliveryAddress type="ElementArray" name="Delivery address"> - <Caption type="SimpleText" name="Delivery address caption"> + <Caption type="SimpleText" name="Caption" id="DeliveryAddressCaption"> <FontSize>12</FontSize> <x>448</x> <y>154</y> </Caption> - <Line1 type="SimpleText" name="Delivery address line 1"> + <Line1 type="SimpleText" name="Line 1" id="DeliveryAddress1"> <FontSize>12</FontSize> <x>448</x> <y>166</y> </Line1> - <Line2 type="SimpleText" name="Delivery address line 2"> + <Line2 type="SimpleText" name="Line 2" id="DeliveryAddress2"> <FontSize>12</FontSize> <x>448</x> <y>178</y> </Line2> - <Line3 type="SimpleText" name="Delivery address line 3"> + <Line3 type="SimpleText" name="Line 3" id="DeliveryAddress3"> <FontSize>12</FontSize> <x>448</x> <y>190</y> </Line3> - <Line4 type="SimpleText" name="Delivery address line 4"> + <Line4 type="SimpleText" name="Line 4" id="DeliveryAddress4"> <FontSize>12</FontSize> <x>448</x> <y>202</y> </Line4> - <Line5 type="SimpleText" name="Delivery address line 5"> + <Line5 type="SimpleText" name="Line 5" id="DeliveryAddress5"> <FontSize>12</FontSize> <x>448</x> <y>214</y> </Line5> - <Line6 type="SimpleText" name="Delivery address line 6"> + <Line6 type="SimpleText" name="Line 6" id="DeliveryAddress6"> <FontSize>12</FontSize> <x>448</x> <y>226</y> </Line6> </DeliveryAddress> - <DeliveryAddressBox type="CurvedRectangle" name="Delivery address box"> + <DeliveryAddressBox type="CurvedRectangle" name="Delivery address box" id="DeliveryAddressBox"> <x>446</x> <y>145</y> <width>240</width> <height>80</height> <radius>10</radius> </DeliveryAddressBox> - <SupplierName type="SimpleText" name="Supplier name"> + <SupplierName type="SimpleText" name="Supplier name" id="SupplierName"> <FontSize>12</FontSize> <x>41</x> <y>246</y> </SupplierName> <SupplierAddress type="ElementArray" name="Supplier address"> - <Line1 type="SimpleText" name="Supplier address line 1"> + <Line1 type="SimpleText" name="Line 1" id="SupplierAddress1"> <FontSize>12</FontSize> <x>71</x> <y>262</y> </Line1> - <Line2 type="SimpleText" name="Supplier address line 2"> + <Line2 type="SimpleText" name="Line 2" id="SupplierAddress2"> <FontSize>12</FontSize> <x>71</x> <y>274</y> </Line2> - <Line3 type="SimpleText" name="Supplier address line 3"> + <Line3 type="SimpleText" name="Line 3" id="SupplierAddress3"> <FontSize>12</FontSize> <x>71</x> <y>286</y> </Line3> - <Line4 type="SimpleText" name="Supplier address line 4"> + <Line4 type="SimpleText" name="Line 4" id="SupplierAddress4"> <FontSize>12</FontSize> <x>71</x> <y>298</y> </Line4> </SupplierAddress> - <OrderDate type="SimpleText" name="Order date"> + <OrderDate type="SimpleText" name="Order date" id="OrderDate"> <FontSize>12</FontSize> <x>446</x> <y>262</y> </OrderDate> - <Initiator type="SimpleText" name="Order initiator"> + <Initiator type="SimpleText" name="Order initiator" id="Initiator"> <FontSize>12</FontSize> <x>446</x> <y>278</y> </Initiator> - <PaymentTerms type="SimpleText" name="Payment terms"> + <PaymentTerms type="SimpleText" name="Payment terms" id="PaymentTerms"> <FontSize>12</FontSize> <x>446</x> <y>290</y> </PaymentTerms> - <Comments type="MultiLineText" name="Comments"> + <Comments type="MultiLineText" name="Comments" id="Comments"> <FontSize>12</FontSize> <Length>250</Length> <x>446</x> <y>302</y> </Comments> - <Currency type="SimpleText" name="Currency text"> + <Currency type="SimpleText" name="Currency text" id="Currency"> <FontSize>12</FontSize> <x>40</x> <y>312</y> </Currency> - <HeaderRectangle type="Rectangle" name="Header rectangle"> + <HeaderRectangle type="Rectangle" name="Header rectangle" id="HeaderRectangle"> <x>40</x> <y>320</y> <width>772</width> <height>32</height> </HeaderRectangle> <Headings type="ElementArray" name="Column headings"> - <Column1 type="SimpleText" name="Column heading 1"> + <Column1 type="SimpleText" name="Heading 1" id="Heading1"> <FontSize>10</FontSize> <x>41</x> <y>330</y> </Column1> - <Column2 type="SimpleText" name="Column heading 2"> + <Column2 type="SimpleText" name="Heading 2" id="Heading2"> <FontSize>10</FontSize> <x>136</x> <y>330</y> </Column2> - <Column3 type="SimpleText" name="Column heading 3"> + <Column3 type="SimpleText" name="Heading 3" id="Heading3"> <FontSize>10</FontSize> <x>441</x> <y>330</y> </Column3> - <Column4 type="SimpleText" name="Column heading 4"> + <Column4 type="SimpleText" name="Heading 4" id="Heading4"> <FontSize>10</FontSize> <x>491</x> <y>330</y> </Column4> - <Column5 type="SimpleText" name="Column heading 5"> + <Column5 type="SimpleText" name="Heading 5" id="Heading5"> <FontSize>10</FontSize> <x>526</x> <y>330</y> </Column5> - <Column6 type="SimpleText" name="Column heading 6"> + <Column6 type="SimpleText" name="Heading 6" id="Heading6"> <FontSize>10</FontSize> <x>641</x> <y>330</y> </Column6> - <Column7 type="SimpleText" name="Column heading 7"> + <Column7 type="SimpleText" name="Heading 7" id="Heading7"> <FontSize>10</FontSize> <x>761</x> <y>330</y> </Column7> </Headings> - <DataRectangle type="Rectangle" name="Header rectangle"> + <DataRectangle type="Rectangle" name="Data rectangle" id="DataRectangle"> <x>40</x> <y>352</y> <width>772</width> <height>213</height> </DataRectangle> <Data type="ElementArray" name="Column Data"> - <y>362</y> - <Column1 type="DataText" name="Data column 1"> + <y type="StartLine" name="Y co-ordinate of first data line" id="DataStartLine">362</y> + <Column1 type="DataText" name="Column 1" id="Data1"> <FontSize>10</FontSize> <x>41</x> - <length>94</length> + <Length>94</Length> </Column1> - <Column2 type="DataText" name="Data column 2"> + <Column2 type="DataText" name="Column 2" id="Data2"> <FontSize>10</FontSize> <x>136</x> - <length>270</length> + <Length>270</Length> </Column2> - <Column3 type="DataText" name="Data column 3"> + <Column3 type="DataText" name="Column 3" id="Data3"> <FontSize>10</FontSize> <x>441</x> - <length>85</length> + <Length>85</Length> </Column3> - <Column4 type="DataText" name="Data column 4"> + <Column4 type="DataText" name="Column 4" id="Data4"> <FontSize>10</FontSize> <x>491</x> - <length>37</length> + <Length>37</Length> </Column4> - <Column5 type="DataText" name="Data column 5"> + <Column5 type="DataText" name="Column 5" id="Data5"> <FontSize>10</FontSize> <x>526</x> - <length>60</length> + <Length>60</Length> </Column5> - <Column6 type="DataText" name="Data column 6"> + <Column6 type="DataText" name="Column 6" id="Data6"> <FontSize>10</FontSize> <x>591</x> - <length>85</length> + <Length>85</Length> </Column6> - <Column7 type="DataText" name="Data column 7"> + <Column7 type="DataText" name="Column 7" id="Data7"> <FontSize>10</FontSize> - <x>721</x> - <length>85</length> + <x>661</x> + <Length>130</Length> </Column7> </Data> - <OrderTotalCaption type="SimpleText" name="Order total caption"> + <OrderTotalCaption type="SimpleText" name="Order total caption" id="OrderTotalCaption"> <FontSize>14</FontSize> <x>450</x> <y>549</y> </OrderTotalCaption> - <OrderTotal type="MultiLineText" name="Order total"> + <OrderTotal type="MultiLineText" name="Order total" id="OrderTotal"> <FontSize>14</FontSize> <x>665</x> <y>549</y> - <length>135</length> + <Length>125</Length> </OrderTotal> </form> \ No newline at end of file Modified: trunk/doc/Change.log.html =================================================================== --- trunk/doc/Change.log.html 2010-01-06 09:35:10 UTC (rev 3274) +++ trunk/doc/Change.log.html 2010-01-06 12:19:52 UTC (rev 3275) @@ -1,5 +1,6 @@ <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p> <p> +<p>06/01/10 Tim: Form layout designer - Enable each company to have their own layouts for orders/invoices etc <p>04/01/10 Tim: api_stock.php - Correct typo in sql statement. <p>03/01/10 Phil: Fix SalesAnalysis_UserDefined.php - one too many brackets and indentation <p>02/01/10 Tim: Allow pdf output of the asset register. Modified: trunk/includes/PO_PDFOrderPageHeader.inc =================================================================== --- trunk/includes/PO_PDFOrderPageHeader.inc 2010-01-06 09:35:10 UTC (rev 3274) +++ trunk/includes/PO_PDFOrderPageHeader.inc 2010-01-06 12:19:52 UTC (rev 3275) @@ -5,25 +5,18 @@ a new page is implicit on the establishment of a new pdf object so only for subsequent pages */ - if ($PageNumber>1){ $pdf->newPage(); } - $pdf->addJpegFromFile($_SESSION['LogoFile'],$Left_Margin+$FormDesign->logo->x,$Page_Height- $FormDesign->logo->y,$FormDesign->logo->width,$FormDesign->logo->height); - $pdf->addText($FormDesign->OrderNumber->x,$Page_Height- $FormDesign->OrderNumber->y,$FormDesign->OrderNumber->FontSize, _('Purchase Order Number'). ' ' . $OrderNo); - if ($ViewingOnly!=0) { $pdf->addText($FormDesign->ViewingOnly->x,$Page_Height - $FormDesign->ViewingOnly->y,$FormDesign->ViewingOnly->FontSize, _('FOR VIEWING ONLY') . ', ' . _('DO NOT SEND TO SUPPLIER') ); $pdf->addText($FormDesign->ViewingOnly->x,$Page_Height - $FormDesign->ViewingOnly->y-$line_height,$FormDesign->ViewingOnly->FontSize, _('SUPPLIERS') . ' - ' . _('THIS IS NOT AN ORDER') ); } - $pdf->addText($FormDesign->PageNumber->x,$Page_Height - $FormDesign->PageNumber->y, $FormDesign->PageNumber->FontSize, _('Page') . ': ' .$PageNumber); - /*Now print out the company Tax authority reference */ $pdf->addText($FormDesign->TaxAuthority->x,$Page_Height - $FormDesign->TaxAuthority->y, $FormDesign->TaxAuthority->FontSize, $_SESSION['TaxAuthorityReferenceName'] . ' ' . $_SESSION['CompanyRecord']['gstno']); - /*Now print out the company name and address */ $pdf->addText($FormDesign->CompanyName->x,$Page_Height - $FormDesign->CompanyName->y, $FormDesign->CompanyName->FontSize, $_SESSION['CompanyRecord']['coyname']); $pdf->addText($FormDesign->CompanyAddress->Line1->x,$Page_Height - $FormDesign->CompanyAddress->Line1->y, $FormDesign->CompanyAddress->Line1->FontSize, $_SESSION['CompanyRecord']['regoffice1']); @@ -34,7 +27,6 @@ $pdf->addText($FormDesign->CompanyPhone->x,$Page_Height - $FormDesign->CompanyPhone->y, $FormDesign->CompanyPhone->FontSize, _('Tel'). ': ' . $_SESSION['CompanyRecord']['telephone']); $pdf->addText($FormDesign->CompanyFax->x,$Page_Height - $FormDesign->CompanyFax->y, $FormDesign->CompanyFax->FontSize, _('Fax').': ' . $_SESSION['CompanyRecord']['fax']); $pdf->addText($FormDesign->CompanyEmail->x,$Page_Height - $FormDesign->CompanyEmail->y, $FormDesign->CompanyEmail->FontSize, _('Email'). ': ' .$_SESSION['CompanyRecord']['email']); - /*Now the delivery details */ $pdf->addText($FormDesign->DeliveryAddress->Caption->x,$Page_Height - $FormDesign->DeliveryAddress->Caption->y, $FormDesign->DeliveryAddress->Caption->FontSize, _('Deliver To') . ':' ); $pdf->addText($FormDesign->DeliveryAddress->Line1->x,$Page_Height - $FormDesign->DeliveryAddress->Line1->y, $FormDesign->DeliveryAddress->Line1->FontSize, $POHeader['deladd1']); @@ -43,10 +35,8 @@ $pdf->addText($FormDesign->DeliveryAddress->Line4->x,$Page_Height - $FormDesign->DeliveryAddress->Line4->y, $FormDesign->DeliveryAddress->Line4->FontSize, $POHeader['deladd4']); $pdf->addText($FormDesign->DeliveryAddress->Line5->x,$Page_Height - $FormDesign->DeliveryAddress->Line5->y, $FormDesign->DeliveryAddress->Line5->FontSize, $POHeader['deladd5']); $pdf->addText($FormDesign->DeliveryAddress->Line6->x,$Page_Height - $FormDesign->DeliveryAddress->Line6->y, $FormDesign->DeliveryAddress->Line6->FontSize, $POHeader['deladd6']); - /*draw a nice curved corner box around the delivery to address */ $pdf->RoundRectangle($FormDesign->DeliveryAddressBox->x, $Page_Height - $FormDesign->DeliveryAddressBox->y,$FormDesign->DeliveryAddressBox->width, $FormDesign->DeliveryAddressBox->height, $FormDesign->DeliveryAddressBox->radius); - /*Now the Supplier details */ $pdf->addText($FormDesign->SupplierName->x,$Page_Height - $FormDesign->SupplierName->y, $FormDesign->SupplierName->FontSize, _('To').': '); $pdf->addText($FormDesign->SupplierName->x+30,$Page_Height - $FormDesign->SupplierName->y, $FormDesign->SupplierName->FontSize, $POHeader['suppname']); @@ -54,33 +44,31 @@ $pdf->addText($FormDesign->SupplierAddress->Line2->x,$Page_Height - $FormDesign->SupplierAddress->Line2->y, $FormDesign->SupplierAddress->Line2->FontSize, $POHeader['address2']); $pdf->addText($FormDesign->SupplierAddress->Line3->x,$Page_Height - $FormDesign->SupplierAddress->Line3->y, $FormDesign->SupplierAddress->Line3->FontSize, $POHeader['address3']); $pdf->addText($FormDesign->SupplierAddress->Line4->x,$Page_Height - $FormDesign->SupplierAddress->Line4->y, $FormDesign->SupplierAddress->Line4->FontSize, $POHeader['address4']); - /*Now the Order date */ $pdf->addText($FormDesign->OrderDate->x,$Page_Height - $FormDesign->OrderDate->y, $FormDesign->OrderDate->FontSize, _('Order Date') . ':' ); $pdf->addText($FormDesign->OrderDate->x+70,$Page_Height - $FormDesign->OrderDate->y, $FormDesign->OrderDate->FontSize, ConvertSQLDate($POHeader['orddate'])); - /*Now the Initiator */ $pdf->addText($FormDesign->Initiator->x,$Page_Height - $FormDesign->Initiator->y, $FormDesign->Initiator->FontSize, _('Initiator').': '); $pdf->addText($FormDesign->Initiator->x+70,$Page_Height - $FormDesign->Initiator->y, $FormDesign->Initiator->FontSize, $POHeader['initiator']); - -/*Find the description of the payment terms and display */ -$sql='SELECT terms FROM paymentterms where termsindicator="'.$POHeader['paymentterms'].'"'; -$termsresult=DB_query($sql, $db); -$myrow=DB_fetch_array($termsresult); -$pdf->addText($FormDesign->PaymentTerms->x,$Page_Height - $FormDesign->PaymentTerms->y, $FormDesign->PaymentTerms->FontSize, _('Payment Terms').' : '.$myrow['terms']); - +/*Find the description of the payment terms and display. + * If it is a preview then just insert dummy data */ +if ($OrderNo != 'Preview') { + $sql='SELECT terms FROM paymentterms where termsindicator="'.$POHeader['paymentterms'].'"'; + $termsresult=DB_query($sql, $db); + $myrow=DB_fetch_array($termsresult); + $pdf->addText($FormDesign->PaymentTerms->x,$Page_Height - $FormDesign->PaymentTerms->y, $FormDesign->PaymentTerms->FontSize, _('Payment Terms').' : '.$myrow['terms']); +} else { + $pdf->addText($FormDesign->PaymentTerms->x,$Page_Height - $FormDesign->PaymentTerms->y, $FormDesign->PaymentTerms->FontSize, _('Payment Terms').' : '.'XXXXXXXX'); +} /*Now the Comments split over two lines if necessary */ $LeftOvers = $pdf->addTextWrap($FormDesign->Comments->x, $Page_Height - $FormDesign->Comments->y,$FormDesign->Comments->Length,$FormDesign->Comments->FontSize,_('Comments') . ':' .$POHeader['comments'], 'left'); if (strlen($LeftOvers)>0){ $LeftOvers = $pdf->addTextWrap($FormDesign->Comments->x, $Page_Height - $FormDesign->Comments->y-$line_height,$FormDesign->Comments->Length,$FormDesign->Comments->FontSize,$LeftOvers, 'left'); } - /*Now the currency the order is in */ $pdf->addText($FormDesign->Currency->x,$Page_Height - $FormDesign->Currency->y,$FormDesign->Currency->FontSize, _('All amounts stated in').' - ' . $POHeader['currcode']); - /*draw a square grid for entering line headings */ $pdf->Rectangle($FormDesign->HeaderRectangle->x, $Page_Height - $FormDesign->HeaderRectangle->y, $FormDesign->HeaderRectangle->width,$FormDesign->HeaderRectangle->height); - /*Set up headings */ $pdf->addText($FormDesign->Headings->Column1->x,$Page_Height - $FormDesign->Headings->Column1->y, $FormDesign->Headings->Column1->FontSize, _('Code') ); $pdf->addText($FormDesign->Headings->Column2->x,$Page_Height - $FormDesign->Headings->Column2->y, $FormDesign->Headings->Column2->FontSize, _('Item Description') ); @@ -89,8 +77,6 @@ $pdf->addText($FormDesign->Headings->Column5->x,$Page_Height - $FormDesign->Headings->Column5->y, $FormDesign->Headings->Column5->FontSize, _('Date Reqd')); $pdf->addText($FormDesign->Headings->Column6->x,$Page_Height - $FormDesign->Headings->Column6->y, $FormDesign->Headings->Column6->FontSize, _('Price') ); $pdf->addText($FormDesign->Headings->Column7->x,$Page_Height - $FormDesign->Headings->Column7->y, $FormDesign->Headings->Column7->FontSize, _('Total') ); - /*draw a rectangle to hold the data lines */ $pdf->Rectangle($FormDesign->DataRectangle->x, $Page_Height - $FormDesign->DataRectangle->y, $FormDesign->DataRectangle->width,$FormDesign->DataRectangle->height); - ?> \ No newline at end of file Modified: trunk/index.php =================================================================== --- trunk/index.php 2010-01-06 09:35:10 UTC (rev 3274) +++ trunk/index.php 2010-01-06 12:19:52 UTC (rev 3275) @@ -778,7 +778,7 @@ <?php echo '<p>• <a href="' . $rootpath . '/BOMs.php?' . SID . '">' . _('Bills Of Material') . '</a></p>'; ?> </td> </tr> - + <tr> <td class="menu_group_item"> <?php echo '<p>• <a href="' . $rootpath . '/MRPDemands.php?' . SID . '">' . _('Master Schedule') . '</a></p>'; ?> @@ -794,7 +794,7 @@ <?php echo '<p>• <a href="' . $rootpath . '/MRP.php?' . SID . '">' . _('MRP Calculation') . '</a></p>'; ?> </td> </tr> - + </table> </td> </tr> @@ -933,6 +933,11 @@ <?php echo '<p>• <a href="' . $rootpath . '/GeocodeSetup.php">' . _('Geocode Setup') . '</a></p>'; ?> </td> </tr> + <tr> + <td class="menu_group_item"> + <?php echo '<p>• <a href="' . $rootpath . '/FormDesigner.php">' . _('Form Layout Editor') . '</a></p>'; ?> + </td> + </tr> </table> </td> @@ -1029,7 +1034,7 @@ </td> </tr> <tr></tr> - + <tr> <td class="menu_group_item"> <?php echo '<p>• <a href="' . $rootpath . '/MRPCalendar.php?' . SID . '">' . _('MRP Available Production Days') . '</a></p>'; ?> @@ -1235,7 +1240,7 @@ </td> </tr> </table> -<?php +<?php break; } //end of module switch } /* end of if security allows to see the full menu */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |