/**
  * Function called when a Dolibarrr business event is done.
  * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
  *
  * @param string		$action		Event action code
  * @param Object		$object     Object
  * @param User			$user       Object user
  * @param Translate		$langs      Object langs
  * @param conf			$conf       Object conf
  * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
  */
 public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
 {
     // Mettre ici le code a executer en reaction de l'action
     // Les donnees de l'action sont stockees dans $object
     if ($action == 'PAYPAL_PAYMENT_OK') {
         dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". source=" . $object->source . " ref=" . $object->ref);
         if (!empty($object->source)) {
             if ($object->source == 'membersubscription') {
                 //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php';
                 // TODO add subscription treatment
             } else {
                 require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
                 $soc = new Societe($this->db);
                 // Parse element/subelement (ex: project_task)
                 $element = $path = $filename = $object->source;
                 if (preg_match('/^([^_]+)_([^_]+)/i', $object->source, $regs)) {
                     $element = $path = $regs[1];
                     $filename = $regs[2];
                 }
                 // For compatibility
                 if ($element == 'order') {
                     $path = $filename = 'commande';
                 }
                 if ($element == 'invoice') {
                     $path = 'compta/facture';
                     $filename = 'facture';
                 }
                 dol_include_once('/' . $path . '/class/' . $filename . '.class.php');
                 $classname = ucfirst($filename);
                 $obj = new $classname($this->db);
                 $ret = $obj->fetch('', $object->ref);
                 if ($ret < 0) {
                     return -1;
                 }
                 // Add payer id
                 $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid);
                 // Add transaction id
                 $obj->setValueFrom('ref_int', $object->resArray["TRANSACTIONID"]);
             }
         } else {
             // TODO add free tag treatment
         }
     }
     return 0;
 }
示例#2
0
文件: soc.php 项目: ADDAdev/Dolibarr
     // We defined value code_fournisseur
     $_POST["code_fournisseur"] = "Acompleter";
 }
 if ($action == 'set_localtax1') {
     //obtidre selected del combobox
     $value = GETPOST('lt1');
     $object = new Societe($db);
     $object->fetch($socid);
     $res = $object->setValueFrom('localtax1_value', $value);
 }
 if ($action == 'set_localtax2') {
     //obtidre selected del combobox
     $value = GETPOST('lt2');
     $object = new Societe($db);
     $object->fetch($socid);
     $res = $object->setValueFrom('localtax2_value', $value);
 }
 // Add new or update third party
 if (!GETPOST('getcustomercode') && !GETPOST('getsuppliercode') && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) {
     require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
     if ($action == 'update') {
         $ret = $object->fetch($socid);
         $object->oldcopy = dol_clone($object);
     } else {
         $object->canvas = $canvas;
     }
     if (GETPOST("private") == 1) {
         $object->particulier = GETPOST("private");
         $object->name = dolGetFirstLastname(GETPOST('firstname', 'alpha'), GETPOST('nom', 'alpha') ? GETPOST('nom', 'alpha') : GETPOST('name', 'alpha'));
         $object->civility_id = GETPOST('civility_id', 'int');
         // Add non official properties