Jump to content

elentz

Members
  • Posts

    228
  • Joined

  • Last visited

Everything posted by elentz

  1. I want to use a variable in a text area inside a Function. Here is my code function Header() { //Logo $this->Image('cqilogo.PNG',5,4,50); //Arial bold 15 $this->SetFont('Arial','B',15); //Move to the right $this->Cell(75); //Title $this->Cell(100,10,'Proposal',1,0,'C'); $this->SetFont('Arial','',10); $this->Setxy(6,30); $this->Cell(200,10,'5103 Eastman ,0,1,'C'); $this->Line(16,40,200,40);//**16 is the starting point, 200 is the end point and 57 is the position on the page //Line break $this->Ln(1); } I have a variable $proposalid that I want at the end of (100,10,'Proposal $proposalid',1,0,'C'); I've tried to include it in "" and '' and the variable won't show. I can use it in other areas of my script. Is it because it is inside a Function that it won't work? Thanks
  2. Well, That yielded ALOT! Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44 Notice: Undefined variable: column_productname in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 45 Notice: Undefined variable: column_quantity in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 43 Notice: Undefined variable: column_productcode in /var/www/cqicrm5/customstuff/forms/fpdfmysql.php on line 44
  3. Arghhhh! I tried the script with the error reporting and still got the blank page.
  4. Yeah the working version printed all the products I created in my test (4).
  5. I am confused now. I used some code I got and changed the query and the variables around. Here is the original code //Select the Products you want to show in your PDF file $result=mysql_query("select Code,Name,Price from Products ORDER BY Code",$link); $number_of_products = mysql_numrows($result); //Initialize the 3 columns and the total $column_code = ""; $column_name = ""; $column_price = ""; $total = 0; //For each row, add the field to the corresponding column while($row = mysql_fetch_array($result)) { $code = $row["Code"]; $name = substr($row["Name"],0,20); $real_price = $row["Price"]; $price_to_show = number_format($row["Price"],',','.','.'); $column_code = $column_code.$code."\n"; $column_name = $column_name.$name."\n"; $column_price = $column_price.$price_to_show."\n"; //Sum all the Prices (TOTAL) $total = $total+$real_price; } mysql_close(); //Convert the Total Price to a number with (.) for thousands, and (,) for decimals. $total = number_format($total,',','.','.'); //Create a new PDF file $pdf=new FPDF(); $pdf->AddPage(); //Fields Name position $Y_Fields_Name_position = 20; //Table position, under Fields Name $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(45); $pdf->Cell(20,6,'CODE',1,0,'L',1); $pdf->SetX(65); $pdf->Cell(100,6,'NAME',1,0,'L',1); $pdf->SetX(135); $pdf->Cell(30,6,'PRICE',1,0,'R',1); $pdf->Ln(); //Now show the 3 columns $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position); $pdf->SetX(45); $pdf->MultiCell(20,6,$column_code,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(65); $pdf->MultiCell(100,6,$column_name,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(135); $pdf->MultiCell(30,6,$column_price,1,'R'); $pdf->SetX(135); $pdf->MultiCell(30,6,'$ '.$total,1,'R'); //Create lines (boxes) for each ROW (Product) //If you don't use the following code, you don't create the lines separating each row $i = 0; $pdf->SetY($Y_Table_Position); while ($i < $number_of_products) { $pdf->SetX(45); $pdf->MultiCell(120,6,'',1); $i = $i +1; } $pdf->Output(); If I add my DB connection and use a DB and table that matches what this script is looking for it works fine. So changing the while loop is confusing to me, if it works with this code and not the other.
  6. Thanks for the help so far. I deleted the Mysql Close and got the same result. Any other suggestions, Does anyone know of a tutorial that explains what or the mechanics of extracting the data. Thanks
  7. I know this must be simple, I have been staring at this for a long time and can't get it figured out. I know the problem is in the result of the query, getting the right row data. I have tested the query and it does get the info I need. $sql= "SELECT vtiger_inventoryproductrel.quantity, vtiger_products.productcode, vtiger_products.productname FROM vtiger_inventoryproductrel Inner Join vtiger_products ON vtiger_inventoryproductrel.productid = vtiger_products.productid Inner Join vtiger_productcf ON vtiger_products.productid = vtiger_productcf.productid WHERE vtiger_inventoryproductrel.id = '17898'"; //Select the Products you want to show in your PDF file $result=mysql_query($sql); $number_of_products = mysql_numrows($result); //For each row, add the field to the corresponding column while($row = mysql_fetch_array($result)) { $qnty = $row["quantity"]; $part = $row["productcode"]; $desc = $row["productname"]; $column_qnty = $column_quantity.$qnty."\n"; $column_part = $column_productcode.$part."\n"; $column_desc = $column_productname.$desc"\n";} mysql_close(); //Create a new PDF file $pdf=new FPDF(); $pdf->AddPage(); //Fields Name position $Y_Fields_Name_position = 20; //Table position, under Fields Name $Y_Table_Position = 26; //First create each Field Name //Gray color filling each Field Name box $pdf->SetFillColor(232,232,232); //Bold Font for Column Field Name $pdf->SetFont('Arial','B',12); $pdf->SetY($Y_Fields_Name_position); $pdf->SetX(45); $pdf->Cell(20,6,'Qnty',1,0,'L',1); $pdf->SetX(65); $pdf->Cell(30,6,'Part #',1,0,'L',1); $pdf->SetX(135); $pdf->Cell(100,6,'Description',1,0,'R',1); $pdf->Ln(); //Now show the 3 columns $pdf->SetFont('Arial','',12); $pdf->SetY($Y_Table_Position); $pdf->SetX(45); $pdf->MultiCell(20,6,$column_qnty,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(65); $pdf->MultiCell(30,6,$column_part,1); $pdf->SetY($Y_Table_Position); $pdf->SetX(135); $pdf->MultiCell(100,6,$column_desc,1,'R'); $pdf->SetX(135); //Create lines (boxes) for each ROW (Product) //If you don't use the following code, you don't create the lines separating each row $i = 0; $pdf->SetY($Y_Table_Position); while ($i < $number_of_products) { $pdf->SetX(45); $pdf->MultiCell(120,6,'',1); $i = $i +1; } $pdf->Output(); ?> When I open the page I get nothing (blank page) I got this script form the FPDF site and all I did was change the query and the variable names, and the connection to the DB. I created table in my DB that coincided with what the original script used and I got the page results I wanted. I just don't see where I went wrong. Thanks alot for any help!
  8. I am sure an array will be needed but probably not hard coded. There will be a one to many relationship. Each time we sell a system we need to scan a number (meaning several from 10 - 100) of serialnumbers. An array with the common info for each serialnumber table entry. Somehow an array would need to be created and then used for each time a serialnumber is scanned.
  9. I am trying to figure out how to do this. I need to keep track or serial numbers for products I sell. There is a common id that links the serial numbers to a customer. I need to keep track of: customerid, serialnumber, vendor, datescanned, warrantyinterval. I will be using a barcode scanner to collect the serial numbers. Ideally I want to enter all the info except the serialnumber only once per session (session here being the actual time it takes to make all the entries). I have a MySql table that all this will be inserted into. The barcode scanner will scan the code and send a "return" to update the field. Could an array work for all the stuff that needs to be "common" with each new serialnumber that is added? I don't know. I am looking for suggestions Thanks for looking
  10. I've gotten a little farther in my quest. Using this query I can get all the items in a single quote grouped but it will not add the quantities of similar productcode items. The reason for this is that I get parts that come with a kit and then I need to add some of the same parts to finish out the quote. The whole purpose of this is to get an overall count on all the things that need to be ordered. SELECT Sum(vtiger_inventoryproductrel.quantity), vtiger_products.productcode, vtiger_products.productname, vtiger_inventoryproductrel.listprice, vtiger_inventoryproductrel.id FROM vtiger_inventoryproductrel Inner Join vtiger_products ON vtiger_products.productid = vtiger_inventoryproductrel.productid Inner Join vtiger_productcf ON vtiger_productcf.productid = vtiger_products.productid WHERE vtiger_inventoryproductrel.id = '18455' GROUP BY vtiger_products.productcode, vtiger_products.productname, vtiger_inventoryproductrel.listprice, vtiger_inventoryproductrel.id I also need to be able to add more of the vtiger_inventoryproductrelid. If I use one id then I get a result, if I use something like vtieger_inventoryproductrelid = 1234 and 5678 then I get no results. Thanks for any insight you can share
  11. I probably didn't state what I need very well in the subject, but here goes. I have a CRM system that allows me to create quotes to my customers. Sometimes we will have to put together a quote for the same customer but different quotes for separate locations. Within each quote there would be common items. What I would like to do is have a query that would do a sum of all the items, for instance if two quotes had 3 widgets in one and 5 widgets in the other then the query result would show 8 widgets. Of course this is an over simplification, there could and would be many common items between the quotes. Here is a query that I use to get the single quote items. SELECT vtiger_inventoryproductrel.quantity, vtiger_products.productcode, vtiger_products.mfr_part_no, vtiger_products.productname, vtiger_productcf.cf_450, vtiger_inventoryproductrel.listprice, quantity * cf_450 AS ext_cost, listprice * quantity AS ext_quote FROM vtiger_inventoryproductrel Inner Join vtiger_products ON vtiger_products.productid = vtiger_inventoryproductrel.productid Inner Join vtiger_productcf ON vtiger_productcf.productid = vtiger_products.productid WHERE vtiger_inventoryproductrel.comment NOT LIKE 'Part of Kit' AND vtiger_inventoryproductrel.id = '$myvar' The variable '$myvar' I am using from a page to get the quote number, I am using it on a page that uses baaGrid to list all the parts for that particular quote. Any help is greatly appreciated!
  12. Thanks I hadn't thought of joining the tables in a query Here's what I have so far: SELECT vtiger_pricebookcf.cf_704, vtiger_pricebook.bookname, vtiger_pricebook.pricebookid, vtiger_pricebook.description, vtiger_pricebookcf.pricebookid, vtiger_pricebook.active, vtiger_pricebookproductrel.productid, vtiger_pricebookproductrel.listprice, vtiger_productcf.cf_450 FROM vtiger_pricebook Inner Join vtiger_pricebookcf ON vtiger_pricebook.pricebookid = vtiger_pricebookcf.pricebookid Inner Join vtiger_pricebookproductrel ON vtiger_pricebookcf.pricebookid = vtiger_pricebookproductrel.pricebookid Inner Join vtiger_productcf ON vtiger_pricebookproductrel.productid = vtiger_productcf.productid This gets me a list or output of all the products info. Now I need to insert into vtiger_pricebookproductrel.listprice the result of vtiger_productcf.cf_450 * vtiger_pricebookproductrel.listprice into table vtiger_pricebookproductrel In the end I need new info into the vtiger_pricebookproductrel table including the pricebookid, and the listprice. How difficult is that? Thanks
  13. Can someone give me an example? I have an update query that uses two manual inputs from a PHP page. I put in the recordid and the multiplier and it changes pricing for all the products by the second amount. Ths issue is that I have 13 records (and it could grow) and it is getting tiresome to manually put in the info. Here's my query: $query="INSERT INTO vtiger_pricebookproductrel ( pricebookid , productid , listprice ) select (".$fieldvalue1.") , productid , (unit_price *.769) * (".$fieldvalue2.") from vtiger_products"; $fieldvalue1 and $fieldvalue2 would be the variables that I need to use from a different table. The table only has two fields, recordid and markup. Ideally I would like to setup a PHP page to do this with a button and some sort of status , but that is icing on the cake, for now getting the query to work would be great. Any advice is appreciated
  14. I am using Baagrid for a simple table from a Mysql DB. the grid works just fine. The question is how can I center it on the page? I didn't see anything in the SetTable attributes that would help. Thanks alot for any suggestions.
  15. I can get a single grid on a page, pretty much no problem. Is it possible to have two Baagrid tables on the same page from different queries? I didn't see anything in the Baagrid samples. Thanks
  16. I was wrong!! The test DB I was using had that field at50 changing it to 255 like the production system and it works! Thanks for the help! Happy Thanksgiving
  17. The field is a VarChar(255) so that should be OK
  18. I am trying to get a Concat query to add put some text into a mysql field along with adding another field value at the end I have: update vtiger_accountscf Set vtiger_accountscf.cf_700 = CONCAT('localhost/customstuff/statements/ex.php?accountid=',(accountid)) I get localhost/customstuff/statements/ex.php?accountid= and that is all. the last accountid is a field in the vtigeraccounts_cf table. When I run the query I never get the accountid added to the line. Can someone show me where I am going wrong here? Thanks Alot
  19. I got a blank page with that code as well. Just to make sure I am explaining what I have. I have a url for the 2nd page that I want to pass the variable $record from the parent page. I only have the url from the parent page to work with. Could the record number be in an array? Thanks again
  20. I have a php page that I want to link to from another page. The original page url is :http://192.168.3.253/index.php?action=DetailView&module=Accounts&parenttab=Support&record=3985&viewname=0 I want to use the record number (in this case 39858) in my php script. I only have the url to work with, I cannot change the code that creates the page I get this record number from. I have tried a simple Get and POST and tried to echo the record number with no results. Can someone help me with a clue on how to do this? Thanks alot
  21. I figured it out, the last query works if I remove all the header cells, having the alias was messing up the table header for some reason. So that part I can fix easily (I think). I am assuming that I can format the total with commas, and 2 digits for dollar amounts, similarily to what is done with the dates. and I need to change the cell widths. Thanks for all your help and patience!
  22. Yeah, that one is the one that allows the pdf to be created but without any date info in the columns.
  23. Sorry about not using the tags I forgot as I was using the quick reply. Using the Date_Format in the query as you have provided, when I run the PDF script the table is created just fine but without any data in the date columns. So maybe you are right that I need to use aliases, maybe that is why the dates are missing?
  24. When I plug in the query that you last offered I get the PDF (which is more than I have gotten since I have been messing around with this!) but, the date columns are blank, so that's not so good. So here is the complete code (including the included file for creating the table (sorry I just remembered that was part of this !) Included file: <?php require('fpdf.php'); class PDF_MySQL_Table extends FPDF { var $ProcessingTable=false; var $aCols=array(); var $TableX; var $HeaderColor; var $RowColors; var $ColorIndex; function Header() { //Print the table header if necessary if($this->ProcessingTable) $this->TableHeader(); } function TableHeader() { $this->SetFont('Arial','B',10); $this->SetX($this->TableX); $fill=!empty($this->HeaderColor); if($fill) $this->SetFillColor($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]); foreach($this->aCols as $col) $this->Cell($col['w'],6,$col['c'],1,0,'C',$fill); $this->Ln(); } function Row($data) { $this->SetX($this->TableX); $ci=$this->ColorIndex; $fill=!empty($this->RowColors[$ci]); if($fill) $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); foreach($this->aCols as $col) $this->Cell($col['w'],5,$data[$col['f']],1,0,$col['a'],$fill); $this->Ln(); $this->ColorIndex=1-$ci; } function CalcWidths($width,$align) { //Compute the widths of the columns $TableWidth=0; foreach($this->aCols as $i=>$col) { $w=$col['w']; if($w==-1) $w=$width/count($this->aCols); elseif(substr($w,-1)=='%') $w=$w/100*$width; $this->aCols[$i]['w']=$w; $TableWidth+=$w; } //Compute the abscissa of the table if($align=='C') $this->TableX=max(($this->w-$TableWidth)/2,0); elseif($align=='R') $this->TableX=max($this->w-$this->rMargin-$TableWidth,0); else $this->TableX=$this->lMargin; } function AddCol($field=-1,$width=-1,$caption='',$align='L') { //Add a column to the table if($field==-1) $field=count($this->aCols); $this->aCols[]=array('f'=>$field,'c'=>$caption,'w'=>$width,'a'=>$align); } function Table($query,$prop=array()) { //Issue query $res=mysql_query($query) or die('Error: '.mysql_error()."<BR>Query: $query"); //Add all columns if none was specified if(count($this->aCols)==0) { $nb=mysql_num_fields($res); for($i=0;$i<$nb;$i++) $this->AddCol(); } //Retrieve column names when not specified foreach($this->aCols as $i=>$col) { if($col['c']=='') { if(is_string($col['f'])) $this->aCols[$i]['c']=ucfirst($col['f']); else $this->aCols[$i]['c']=ucfirst(mysql_field_name($res,$col['f'])); } } //Handle properties if(!isset($prop['width'])) $prop['width']=0; if($prop['width']==0) $prop['width']=$this->w-$this->lMargin-$this->rMargin; if(!isset($prop['align'])) $prop['align']='C'; if(!isset($prop['padding'])) $prop['padding']=$this->cMargin; $cMargin=$this->cMargin; $this->cMargin=$prop['padding']; if(!isset($prop['HeaderColor'])) $prop['HeaderColor']=array(); $this->HeaderColor=$prop['HeaderColor']; if(!isset($prop['color1'])) $prop['color1']=array(); if(!isset($prop['color2'])) $prop['color2']=array(); $this->RowColors=array($prop['color1'],$prop['color2']); //Compute column widths $this->CalcWidths($prop['width'],$prop['align']); //Print header $this->TableHeader(); //Print rows $this->SetFont('Arial','',9); $this->ColorIndex=0; $this->ProcessingTable=true; while($row=mysql_fetch_array($res)) $this->Row($row); $this->ProcessingTable=false; $this->cMargin=$cMargin; $this->aCols=array(); } } ?> PDF Creation file: <?php define('FPDF_FONTPATH','font/'); require('mysql_table.php'); class PDF extends PDF_MySQL_Table { function Header() { //Title $this->SetFont('Arial','',18); $this->Cell(0,50,'Account Statement',0,1,'C'); //the second number in the Cell(x,yy,) is the vertical position of the line $this->Ln(10); //Ensure table header is output parent::Header(); } } //Connect to database mysql_connect('localhost','admin','9axmy425'); mysql_select_db('vtigercrm50'); //***********Get Billing Info ************** $sql = "SELECT `vtiger_account`.`accountname`, `vtiger_accountbillads`.`accountaddressid`, `vtiger_accountbillads`.`bill_street`, `vtiger_accountbillads`.`bill_city`, `vtiger_accountbillads`.`bill_state`, `vtiger_accountbillads`.`bill_code`, `vtiger_account`.`phone`, `vtiger_account`.`fax` FROM `vtiger_account` Inner Join `vtiger_accountbillads` ON `vtiger_account`.`accountid` = `vtiger_accountbillads`.`accountaddressid` WHERE `vtiger_account`.`accountid` = '4103'"; $result=mysql_query($sql); $row=mysql_fetch_assoc($result); $customername =$row['accountname']; $fax=$row['fax']; $address=$row['bill_street']; $city=$row['bill_city']; $state=$row['bill_state']; $code=$row['bill_code']; $phone=$row['phone']; //*************Close ******************* $pdf=new PDF(); $pdf->Open(); $pdf->AddPage(); $pdf->Image('cqilogo.png',5,4,50); $pdf->SetFont('Times','B',12); $pdf->Cell(1,-55,'Customer :'); $pdf->SetFont('Times','',10); $pdf->Cell(1,-45,$customername); $pdf->Cell(-1,-38,$address); $pdf->Cell(1,-31,$city); $pdf->AddCol('invoice_no',20,'Inv. #','L'); $pdf->AddCol('invoicestatus',30,'Status','L'); $pdf->AddCol('subject',80,'Synposis','L'); $pdf->AddCol('total',25,'Total','R'); $pdf->AddCol('invoicedate',25,'Invoice Date','L'); $pdf->AddCol('cf_674',25,'Date Paid','L'); $prop=array('HeaderColor'=>array(255,150,100), // 'color1'=>array(210,245,255), // 'color2'=>array(255,255,210), 'padding'=>2); $pdf->Table("SELECT vtiger_invoice.invoice_no, vtiger_invoice.invoicestatus, vtiger_invoice.subject, vtiger_invoice.total, vtiger_invoice.invoicedate, vtiger_invoicecf.cf_674 FROM vtiger_invoice Inner Join vtiger_invoicecf ON vtiger_invoicecf.invoiceid = vtiger_invoice.invoiceid WHERE vtiger_invoice.accountid = 4103 ORDER BY vtiger_invoice.accountid ASC",$prop); $pdf->Output(); ?> Thanks Ed
  25. Thanks for the replies. I tried your suggestion Ben and I got this: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%m/%d/%Y), DATE_FORMAT(vtiger_invoicecf.cf_674,%m/%d/%Y) FROM vtiger_invoice Inn' at line 6 Query: SELECT vtiger_invoice.invoice_no, vtiger_invoice.invoicestatus, vtiger_invoice.subject, vtiger_invoice.total, DATE_FORMAT(vtiger_invoice.invoicedate,%m/%d/%Y), DATE_FORMAT(vtiger_invoicecf.cf_674,%m/%d/%Y) FROM vtiger_invoice Inner Join vtiger_invoicecf ON vtiger_invoicecf.invoiceid = vtiger_invoice.invoiceid WHERE vtiger_invoice.accountid = 4103 ORDER BY vtiger_invoice.accountid ASC
×
×
  • 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.