<div dir="ltr">Hi!<div><br></div><div>To do this, I simply make a SQL query to update values.</div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><div><br></div><div>Regards,</div><div><br></div><div><div><font color="#666666">Jonathan SARDO</font></div><div></div><div style="color:rgb(136,136,136)"><img src="cid:ii_13df029e6cb01b67" alt="Images intégrées 5"><br></div></div><div style="color:rgb(136,136,136)"><br></div></div></div></div></div><div class="gmail_quote">2014-12-03 23:19 GMT+01:00 Hamono, Chris (DPC) <span dir="ltr"><<a href="mailto:Chris.Hamono@sa.gov.au" target="_blank">Chris.Hamono@sa.gov.au</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-AU" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I will say that’s just crazy. I assume this is a legacy code problem. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Chris<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:vtigercrm-developers-bounces@lists.vtigercrm.com" target="_blank">vtigercrm-developers-bounces@lists.vtigercrm.com</a> [mailto:<a href="mailto:vtigercrm-developers-bounces@lists.vtigercrm.com" target="_blank">vtigercrm-developers-bounces@lists.vtigercrm.com</a>] <b>On Behalf Of </b>Satish Dvnk<br><b>Sent:</b> Wednesday, 3 December 2014 5:17 PM<br><b>To:</b> <a href="mailto:vtigercrm-developers@lists.vtigercrm.com" target="_blank">vtigercrm-developers@lists.vtigercrm.com</a><br><b>Subject:</b> Re: [Vtigercrm-developers] Saving an invoice - What am I doing wrong?<u></u><u></u></span></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Hi Chris,<br><br>While saving the details of Invoice line items, we are removing the existing information of line items and expecting the updated line items information from $_REQUEST.<u></u><u></u></p></div><div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><div><div><p class="MsoNormal"><b><span style="font-family:"Verdana","sans-serif";color:#999999;background:white">regards,</span></b><b><span style="font-family:"Verdana","sans-serif""><br>Satish.Dvnk</span></b><u></u><u></u></p></div></div></div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Wed, Dec 3, 2014 at 9:54 AM, Hamono, Chris (DPC) <<a href="mailto:Chris.Hamono@sa.gov.au" target="_blank">Chris.Hamono@sa.gov.au</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">I am programmatically updating a couple of fields in an invoice. When I save the invoice the changes are correctly recorded but it loses the attached product.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">I am using the following code what am I doing wrong?<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> // create the model from the record id</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> $invoiceModel = Vtiger_Record_Model::getInstanceById($invoiceid, "Invoice");</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> </span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> if ($invoiceModel) {</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> // set the fields as supplied</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> foreach ($fields as $key=>$value){</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> $invoiceModel->set($key, $value);</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> }</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> </span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> // set mode to edit</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> $invoiceModel->set('mode', 'edit');</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> </span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> // save</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> $invoiceModel->save();</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> </span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> return $invoiceModel->getData();</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""> }</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">If I var dump the array returned by getData() it correctly shows the product and the changes.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">e.g.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">['invoicestatus'] =>'Paid' <= status changed</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">['cf_738'] =>'BZ-0025028687' <= custom field being updated</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">['invoice_no'] =>'INV405'</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">['productid'] =>2175</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">['quantity'] =>1.000</span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">['listprice'] =>605.00000000</span><span style="font-family:"Calibri","sans-serif""> </span><span style="font-family:"Calibri","sans-serif""><u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif""> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif"">If I then go to the invoice detail page. The changes I have made are correctly saved (in the above I am setting the status field to ‘Paid’ and setting a custom field) but the invoice no longer has any products attached to it.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888">Chris<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888"> <u></u><u></u></span></p></div></div><p class="MsoNormal"><br>_______________________________________________<br><a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div><br>_______________________________________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br></div></div>