[Vtigercrm-developers] How to update the invoice status to"expiration soon" 7 days before the due date

忍.... 896177346 at qq.com
Sat May 10 06:29:37 GMT 2014


Hello everyone,

we have writed the php script to update the salesorder status to  "expiration soon"  7 days before the end period , and add it to cron run every 15 minutes, the script run perfectly and the salesorder status are also automatically changed to "expiration soon"  if current date is  7 days before the end period. 

then we created a  workflow  until the first time the condition is ture and set the condition:  salesorder status = expiration soon.
excute task: send mail and send sms.

our problem is that vtiger can not trigger the workflow after update the field through php script or update database directly,  it seems that vtiger can only trigger the workflow by save action, 

are there anyone can fix it ?  the full php script we used is the following:


 <?php

require_once('modules/SalesOrder/SalesOrder.php');

/**
 This function is used to UPDATE the field "sostatus" of vtiger_salesorder when 7 days later is end_period day.
 */
$sql =$adb->pquery("SELECT salesorderid FROM vtiger_invoice_recurring_info INNER JOIN vtiger_crmentity ON vtiger_invoice_recurring_info.salesorderid=vtiger_crmentity.crmid WHERE   YEAR(end_period) = YEAR(CURRENT_DATE) AND MONTH(end_period) = MONTH(CURRENT_DATE) AND DAYOFMONTH(end_period) = DAYOFMONTH(CURRENT_DATE)+7  AND vtiger_crmentity.deleted=0",array());
if($adb->num_rows($sql)>0)
{
     $assign_array=array();
     while($fetch = $adb->fetch_array($sql))
     {
          $salesorderid=$fetch["salesorderid"];
          mysql_query("UPDATE vtiger_salesorder SET sostatus = 'expiration soon' WHERE vtiger_salesorder.salesorderid =".$salesorderid.";");         
     }
}

?>
  


Regards!
Andy




------------------ Original ------------------
From:  "Siam Translations LLP";<info at siam-translations.com>;
Date:  Fri, May 9, 2014 10:46 AM
To:  "vtigercrm-developers"<vtigercrm-developers at lists.vtigercrm.com>; 

Subject:  Re: [Vtigercrm-developers] How to update the invoice status to"expiration soon" 7 days before the due date



                   Did you heard about workflows in vtiger? I recommend read vtiger     wiki.
     For this generic task use checkbox right under task title in     workflows.
     
     
     Andrew
     
     
     
     On 09-05-2014 9:27 AM, 忍.... wrote:
     
     Hello everyone,
       
       We need to update the invoice status automatically according       different conditions, such as update the invoice status to       "expiration soon"  7 days before the due date,
       so we need to write the php script firstly, then run the php file       by scheduler service cron in the server. we need some help about       how to write the php script,
       
       Anyone know how to write the php script  to update the invoice       status to "expiration soon"  7 days before the due date ?
       
       
       Regards!
       Andy
       
       
       
       
              
       _______________________________________________ http://www.vtiger.com/          
     -- 
       Andrew Smith
       Head of Projects Management
       SIAM Translations 
       Multilingual Information Management for Life Science and         Technology
       
       This message contains confidential information and is         intended for "Recipient". If you are not the intended recipient         you are notified that disclosing, copying, distributing or         taking any action in reliance on the contents of this         information is strictly prohibited. E-mail transmission cannot         be guaranteed to be secure or error-free as information could be         intercepted, corrupted, lost, destroyed, arrive late or         incomplete, or contain viruses. The sender therefore does not         accept liability for any errors or omissions in the contents of         this message, which arise as a result of e-mail transmission. If         verification is required please request a hard-copy version.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140510/42faf2dc/attachment-0001.html>


More information about the vtigercrm-developers mailing list