当前位置: 首页>>代码示例>>PHP>>正文


PHP Interfaces::run_triggers方法代码示例

本文整理汇总了PHP中Interfaces::run_triggers方法的典型用法代码示例。如果您正苦于以下问题:PHP Interfaces::run_triggers方法的具体用法?PHP Interfaces::run_triggers怎么用?PHP Interfaces::run_triggers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Interfaces的用法示例。


在下文中一共展示了Interfaces::run_triggers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Interfaces

 if (!empty($dol_no_mouse_hover)) {
     $_SESSION['dol_no_mouse_hover'] = $dol_no_mouse_hover;
 }
 if (!empty($dol_use_jmobile)) {
     $_SESSION['dol_use_jmobile'] = $dol_use_jmobile;
 }
 dol_syslog("This is a new started user session. _SESSION['dol_login']=" . $_SESSION["dol_login"] . " Session id=" . session_id());
 $db->begin();
 $user->update_last_login_date();
 $loginfo = 'TZ=' . $_SESSION["dol_tz"] . ';TZString=' . $_SESSION["dol_tz_string"] . ';Screen=' . $_SESSION["dol_screenwidth"] . 'x' . $_SESSION["dol_screenheight"];
 $user->trigger_mesg = $loginfo;
 // TODO We should use hook afterLogin here, not a trigger
 // Call triggers
 include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
 $interface = new Interfaces($db);
 $result = $interface->run_triggers('USER_LOGIN', $user, $user, $langs, $conf);
 if ($result < 0) {
     $error++;
 }
 // End call triggers
 // Hooks on successfull login
 $action = '';
 $hookmanager->initHooks(array('login'));
 $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginfo' => $loginfo);
 $reshook = $hookmanager->executeHooks('afterLogin', $parameters, $user, $action);
 // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) {
     $error++;
 }
 if ($error) {
     $db->rollback();
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:31,代码来源:main.inc.php

示例2: delete


//.........这里部分代码省略.........
                $toute_categs ['societe'] = $static_cat->containing($this->id,2);
            }
            if ($this->fournisseur)
            {
                $toute_categs ['fournisseur'] = $static_cat->containing($this->id,1);
            }

            // Remove each "Categorie"
            foreach ($toute_categs as $type => $categs_type)
            {
                foreach ($categs_type as $cat)
                {
                    $cat->del_type($this, $type);
                }
            }

            // Remove contacts
            $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
            $sql.= " WHERE fk_soc = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error .= $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -1 ".$this->error, LOG_ERR);
            }

            // Update link in member table
            $sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
            $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error .= $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -1 ".$this->error, LOG_ERR);
            }

            // Remove ban
            $sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib";
            $sql.= " WHERE fk_soc = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error = $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -2 ".$this->error, LOG_ERR);
            }

            // Remove third party
            $sql = "DELETE from ".MAIN_DB_PREFIX."societe";
            $sql.= " WHERE rowid = " . $id;
            dol_syslog("Societe::Delete sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql))
            {
                $sqr++;
            }
            else
            {
                $this->error = $this->db->lasterror();
                dol_syslog("Societe::Delete erreur -3 ".$this->error, LOG_ERR);
            }

            if ($sqr == 4)
            {
                // Appel des triggers
                include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                $interface=new Interfaces($this->db);
                $result=$interface->run_triggers('COMPANY_DELETE',$this,$user,$langs,$conf);
                if ($result < 0) { $error++; $this->errors=$interface->errors; }
                // Fin appel triggers

                $this->db->commit();

                // Suppression du repertoire document
                $docdir = $conf->societe->dir_output . "/" . $id;
                if (file_exists ($docdir))
                {
                    dol_delete_dir_recursive($docdir);
                }

                return 1;
            }
            else
            {
                $this->db->rollback();
                return -1;
            }
        }

    }
开发者ID:remyyounes,项目名称:dolibarr,代码行数:101,代码来源:societe.class.php

示例3: update

	/**
	 *      Update database for contract line
	 *      @param      user        	User that modify
	 *      @param      notrigger	    0=no, 1=yes (no update trigger)
	 *      @return     int         	<0 if KO, >0 if OK
	 */
	function update($user, $notrigger=0)
	{
		global $conf, $langs;

		// Clean parameters
		$this->fk_contrat=trim($this->fk_contrat);
		$this->fk_product=trim($this->fk_product);
		$this->statut=trim($this->statut);
		$this->label=trim($this->label);
		$this->description=trim($this->description);
		$this->tva_tx=trim($this->tva_tx);
		$this->localtax1_tx=trim($this->localtax1_tx);
		$this->localtax2_tx=trim($this->localtax2_tx);
		$this->qty=trim($this->qty);
		$this->remise_percent=trim($this->remise_percent);
		$this->remise=trim($this->remise);
		$this->fk_remise_except=trim($this->fk_remise_except);
		$this->subprice=price2num($this->subprice);
		$this->price_ht=price2num($this->price_ht);
		$this->total_ht=trim($this->total_ht);
		$this->total_tva=trim($this->total_tva);
		$this->total_localtax1=trim($this->total_localtax1);
		$this->total_localtax2=trim($this->total_localtax2);
		$this->total_ttc=trim($this->total_ttc);
		$this->info_bits=trim($this->info_bits);
		$this->fk_user_author=trim($this->fk_user_author);
		$this->fk_user_ouverture=trim($this->fk_user_ouverture);
		$this->fk_user_cloture=trim($this->fk_user_cloture);
		$this->commentaire=trim($this->commentaire);

		// Check parameters
		// Put here code to add control on parameters values

		// Update request
		$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
		$sql.= " fk_contrat='".$this->fk_contrat."',";
		$sql.= " fk_product=".($this->fk_product?"'".$this->fk_product."'":'null').",";
		$sql.= " statut='".$this->statut."',";
		$sql.= " label='".$this->db->escape($this->label)."',";
		$sql.= " description='".$this->db->escape($this->description)."',";
		$sql.= " date_commande=".($this->date_commande!=''?$this->db->idate($this->date_commande):"null").",";
		$sql.= " date_ouverture_prevue=".($this->date_ouverture_prevue!=''?$this->db->idate($this->date_ouverture_prevue):"null").",";
		$sql.= " date_ouverture=".($this->date_ouverture!=''?$this->db->idate($this->date_ouverture):"null").",";
		$sql.= " date_fin_validite=".($this->date_fin_validite!=''?$this->db->idate($this->date_fin_validite):"null").",";
		$sql.= " date_cloture=".($this->date_cloture!=''?$this->db->idate($this->date_cloture):"null").",";
		$sql.= " tva_tx='".$this->tva_tx."',";
		$sql.= " localtax1_tx='".$this->localtax1_tx."',";
		$sql.= " localtax2_tx='".$this->localtax2_tx."',";
		$sql.= " qty='".$this->qty."',";
		$sql.= " remise_percent='".$this->remise_percent."',";
		$sql.= " remise=".($this->remise?"'".$this->remise."'":"null").",";
		$sql.= " fk_remise_except=".($this->fk_remise_except?"'".$this->fk_remise_except."'":"null").",";
		$sql.= " subprice='".$this->subprice."',";
		$sql.= " price_ht='".$this->price_ht."',";
		$sql.= " total_ht='".$this->total_ht."',";
		$sql.= " total_tva='".$this->total_tva."',";
		$sql.= " total_localtax1='".$this->total_localtax1."',";
		$sql.= " total_localtax2='".$this->total_localtax2."',";
		$sql.= " total_ttc='".$this->total_ttc."',";
		$sql.= " info_bits='".$this->info_bits."',";
		$sql.= " fk_user_author=".($this->fk_user_author >= 0?$this->fk_user_author:"NULL").",";
		$sql.= " fk_user_ouverture=".($this->fk_user_ouverture > 0?$this->fk_user_ouverture:"NULL").",";
		$sql.= " fk_user_cloture=".($this->fk_user_cloture > 0?$this->fk_user_cloture:"NULL").",";
		$sql.= " commentaire='".$this->db->escape($this->commentaire)."'";
		$sql.= " WHERE rowid=".$this->id;

		dol_syslog("ContratLigne::update sql=".$sql, LOG_DEBUG);
		$resql = $this->db->query($sql);
		if ($resql)
		{
			$contrat=new Contrat($this->db);
			$contrat->fetch($this->fk_contrat);
			$result=$contrat->update_statut($user);
		}
		else
		{
			$this->error="Error ".$this->db->lasterror();
			dol_syslog("ContratLigne::update ".$this->error, LOG_ERR);
			return -1;
		}

		if (! $notrigger)
		{
			// Appel des triggers
			include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
			$interface=new Interfaces($this->db);
			$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
			if ($result < 0) { $error++; $this->errors=$interface->errors; }
			// Fin appel triggers
		}

		return 1;
	}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:99,代码来源:contrat.class.php

示例4: update

 /**
  *      Mise a jour de l'objet ligne de commande en base
  *		@return		int		<0 si ko, >0 si ok
  */
 function update($notrigger = 0)
 {
     global $conf, $langs, $user;
     // Clean parameters
     if (empty($this->tva_tx)) {
         $this->tva_tx = 0;
     }
     if (empty($this->localtax1_tx)) {
         $this->localtax1_tx = 0;
     }
     if (empty($this->localtax2_tx)) {
         $this->localtax2_tx = 0;
     }
     if (empty($this->qty)) {
         $this->qty = 0;
     }
     if (empty($this->total_localtax1)) {
         $this->total_localtax1 = 0;
     }
     if (empty($this->total_localtax2)) {
         $this->total_localtax2 = 0;
     }
     if (empty($this->marque_tx)) {
         $this->marque_tx = 0;
     }
     if (empty($this->marge_tx)) {
         $this->marge_tx = 0;
     }
     if (empty($this->remise)) {
         $this->remise = 0;
     }
     if (empty($this->remise_percent)) {
         $this->remise_percent = 0;
     }
     if (empty($this->info_bits)) {
         $this->info_bits = 0;
     }
     if (empty($this->product_type)) {
         $this->product_type = 0;
     }
     if (empty($this->fk_parent_line)) {
         $this->fk_parent_line = 0;
     }
     $this->db->begin();
     // Mise a jour ligne en base
     $sql = "UPDATE " . MAIN_DB_PREFIX . "commandedet SET";
     $sql .= " description='" . $this->db->escape($this->desc) . "'";
     $sql .= " , tva_tx=" . price2num($this->tva_tx);
     $sql .= " , localtax1_tx=" . price2num($this->localtax1_tx);
     $sql .= " , localtax2_tx=" . price2num($this->localtax2_tx);
     $sql .= " , qty=" . price2num($this->qty);
     $sql .= " , subprice=" . price2num($this->subprice) . "";
     $sql .= " , remise_percent=" . price2num($this->remise_percent) . "";
     $sql .= " , price=" . price2num($this->price) . "";
     // TODO A virer
     $sql .= " , remise=" . price2num($this->remise) . "";
     // TODO A virer
     if (empty($this->skip_update_total)) {
         $sql .= " , total_ht=" . price2num($this->total_ht) . "";
         $sql .= " , total_tva=" . price2num($this->total_tva) . "";
         $sql .= " , total_ttc=" . price2num($this->total_ttc) . "";
     }
     $sql .= " , total_localtax1=" . price2num($this->total_localtax1);
     $sql .= " , total_localtax2=" . price2num($this->total_localtax2);
     $sql .= " , info_bits=" . $this->info_bits;
     if ($this->date_start) {
         $sql .= " , date_start='" . $this->db->idate($this->date_start) . "'";
     } else {
         $sql .= ' , date_start=null';
     }
     if ($this->date_end) {
         $sql .= " , date_end='" . $this->db->idate($this->date_end) . "'";
     }
     $sql .= " , product_type=" . $this->product_type;
     $sql .= " , fk_parent_line=" . ($this->fk_parent_line > 0 ? $this->fk_parent_line : "null");
     $sql .= " WHERE rowid = " . $this->rowid;
     dol_syslog("OrderLine::update sql={$sql}");
     $resql = $this->db->query($sql);
     if ($resql) {
         if (!$notrigger) {
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('LINEORDER_UPDATE', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
             }
             // Fin appel triggers
         }
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->error();
         dol_syslog("OrderLine::update Error " . $this->error, LOG_ERR);
         $this->db->rollback();
//.........这里部分代码省略.........
开发者ID:ripasch,项目名称:dolibarr,代码行数:101,代码来源:commande.class.php

示例5: delete


//.........这里部分代码省略.........
				}
			}

			return parent::delete();

			// TODO Supprimer les contacts
			// Remove contacts
			if (!$error) {
				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "socpeople";
				$sql.= " WHERE fk_soc = " . $id;
				dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error .= $this->db->lasterror();
					dol_syslog(get_class($this) . "::delete erreur -1 " . $this->error, LOG_ERR);
				}
			}

			// Update link in member table
			if (!$error) {
				$sql = "UPDATE " . MAIN_DB_PREFIX . "adherent";
				$sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id;
				dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error .= $this->db->lasterror();
					dol_syslog(get_class($this) . "::delete erreur -1 " . $this->error, LOG_ERR);
				}
			}

			// Remove ban
			if (!$error) {
				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_rib";
				$sql.= " WHERE fk_soc = " . $id;
				dol_syslog(get_class($this) . "::Delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error = $this->db->lasterror();
					dol_syslog(get_class($this) . "::Delete erreur -2 " . $this->error, LOG_ERR);
				}
			}

			// Removed extrafields
			//$result=$this->deleteExtraFields($this);
			//if ($result < 0) $error++;

			if (!$error) {
				// Additionnal action by hooks
				include_once(DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php');
				$hookmanager = new HookManager($this->db);
				$hookmanager->initHooks(array('thirdparty_extrafields'));
				$parameters = array();
				$action = 'delete';
				$reshook = $hookmanager->executeHooks('deleteThirdparty', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
				if (!empty($hookmanager->error)) {
					$error++;
					$this->error = $hookmanager->error;
				}
			}

			// Remove third party
			if (!$error) {
				$sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe";
				$sql.= " WHERE rowid = " . $id;
				dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
				if (!$this->db->query($sql)) {
					$error++;
					$this->error = $this->db->lasterror();
					dol_syslog(get_class($this) . "::delete erreur -3 " . $this->error, LOG_ERR);
				}
			}

			if (!$error) {
				// Appel des triggers
				include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
				$interface = new Interfaces($this->db);
				$result = $interface->run_triggers('COMPANY_DELETE', $this, $user, $langs, $conf);
				if ($result < 0) {
					$error++;
					$this->errors = $interface->errors;
				}
				// Fin appel triggers
			}

			if (!$error) {
				$this->db->commit();

				// Delete directory
				$docdir = $conf->societe->multidir_output[$this->entity] . "/" . $id;
				if (file_exists($docdir)) {
					dol_delete_dir_recursive($docdir);
				}

				return 1;
			} else {
				$this->db->rollback();
				return -1;
			}
		}
	}
开发者ID:nrjacker4,项目名称:crm-php,代码行数:101,代码来源:societe.class.php

示例6: resiliate

 /**
  *		Fonction qui resilie un adherent
  *		@param		user		user adherent qui resilie
  *		@return		int			<0 si ko, >0 si ok
  */
 function resiliate($user)
 {
     global $langs, $conf;
     if ($this->statut == 0) {
         dol_syslog(get_class($this) . "::resiliate statut of member does not allow this", LOG_WARNING);
         return 0;
     }
     $this->db->begin();
     $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
     $sql .= " statut = 0";
     $sql .= ", fk_user_valid=" . $user->id;
     $sql .= " WHERE rowid = " . $this->id;
     $result = $this->db->query($sql);
     if ($result) {
         $this->statut = 0;
         $this->use_webcal = $conf->global->PHPWEBCALENDAR_MEMBERSTATUS == 'always' ? 1 : 0;
         // Appel des triggers
         include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
         $interface = new Interfaces($this->db);
         $result = $interface->run_triggers('MEMBER_RESILIATE', $this, $user, $langs, $conf);
         if ($result < 0) {
             $error++;
             $this->errors = $interface->errors;
         }
         // Fin appel triggers
         $this->db->commit();
         return 1;
     } else {
         $this->error = $this->db->error();
         $this->db->rollback();
         return -1;
     }
 }
开发者ID:ripasch,项目名称:dolibarr,代码行数:38,代码来源:adherent.class.php

示例7: setEventMessages

 if ($result) {
     $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
     // Must not contain "
     setEventMessages($mesg, null, 'mesgs');
     $error = 0;
     // Initialisation donnees
     $object->sendtoid = $sendtoid;
     $object->actiontypecode = $actiontypecode;
     $object->actionmsg = $actionmsg;
     $object->actionmsg2 = $actionmsg2;
     $object->fk_element = $object->id;
     $object->elementtype = $object->element;
     // Appel des triggers
     include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
     $interface = new Interfaces($db);
     $result = $interface->run_triggers('BILL_SUPPLIER_SENTBYMAIL', $object, $user, $langs, $conf);
     if ($result < 0) {
         $error++;
         $object->errors = $interface->errors;
     }
     // Fin appel triggers
     if ($error) {
         dol_print_error($db);
     } else {
         // Redirect here
         // This avoid sending mail twice if going out and then back to page
         header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
         exit;
     }
 } else {
     $langs->load("other");
开发者ID:Samara94,项目名称:dolibarr,代码行数:31,代码来源:card.php

示例8: delete

 /**
  * 	Delete object on database and/or on disk
  *
  *	@param	User	$user		User that delete
  *  @param	int		$mode		'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented)
  *	@return	int					<0 if KO, >0 if OK
  */
 function delete($user, $mode = 'all')
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $error = 0;
     $result = 0;
     if ($mode != 'databaseonly') {
         $relativepath = $this->getRelativePath(1);
     }
     // Ex: dir1/dir2/dir3
     dol_syslog(get_class($this) . "::delete remove directory id=" . $this->id . " mode=" . $mode . ($mode == 'databaseonly' ? '' : ' relativepath=' . $relativepath));
     $this->db->begin();
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ecm_directories";
     $sql .= " WHERE rowid=" . $this->id;
     dol_syslog(get_class($this) . "::delete sql=" . $sql);
     $resql = $this->db->query($sql);
     if (!$resql) {
         $this->db->rollback();
         $this->error = "Error " . $this->db->lasterror();
         dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
         return -2;
     }
     if ($mode != 'databaseonly') {
         $file = $conf->ecm->dir_output . "/" . $relativepath;
         $result = @dol_delete_dir($file);
     }
     if ($result || !@is_dir(dol_osencode($file))) {
         $this->db->commit();
     } else {
         $this->error = 'ErrorFailToDeleteDir';
         dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
         $this->db->rollback();
         $error++;
     }
     if (!$error) {
         // Appel des triggers
         include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
         $interface = new Interfaces($this->db);
         $result = $interface->run_triggers('MYECMDIR_DELETE', $this, $user, $langs, $conf);
         if ($result < 0) {
             $error++;
             $this->errors = $interface->errors;
         }
         // Fin appel triggers
     }
     if (!$error) {
         return 1;
     } else {
         return -1;
     }
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:58,代码来源:ecmdirectory.class.php

示例9: delete

 /**
  *	Delete object in database
  *
  *	@param      User	$user        	User that delete
  *  @param      int		$notrigger	    0=launch triggers after, 1=disable triggers
  *	@return		int						<0 if KO, >0 if OK
  */
 function delete($user, $notrigger = 0)
 {
     global $conf, $langs;
     $error = 0;
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "import_model";
     $sql .= " WHERE rowid=" . $this->id;
     $this->db->begin();
     dol_syslog(get_class($this) . "::delete sql=" . $sql);
     $resql = $this->db->query($sql);
     if (!$resql) {
         $error++;
         $this->errors[] = "Error " . $this->db->lasterror();
     }
     if (!$error) {
         if (!$notrigger) {
             // Call triggers
             include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('IMPORT_DELETE', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
             }
             // End call triggers
         }
     }
     // Commit or rollback
     if ($error) {
         foreach ($this->errors as $errmsg) {
             dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
             $this->error .= $this->error ? ', ' . $errmsg : $errmsg;
         }
         $this->db->rollback();
         return -1 * $error;
     } else {
         $this->db->commit();
         return 1;
     }
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:46,代码来源:import.class.php

示例10: delete

 /**
  * 	Delete a category from database
  *
  * 	@param	User	$user		Object user that ask to delete
  *	@return	void
  */
 function delete($user)
 {
     global $conf, $langs;
     $error = 0;
     dol_syslog("Categorie::remove");
     $this->db->begin();
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_societe";
         $sql .= " WHERE fk_categorie = " . $this->id;
         if (!$this->db->query($sql)) {
             $this->error = $this->db->lasterror();
             dol_syslog("Error sql=" . $sql . " " . $this->error, LOG_ERR);
             $error++;
         }
     }
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_fournisseur";
         $sql .= " WHERE fk_categorie = " . $this->id;
         if (!$this->db->query($sql)) {
             $this->error = $this->db->lasterror();
             dol_syslog("Error sql=" . $sql . " " . $this->error, LOG_ERR);
             $error++;
         }
     }
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_product";
         $sql .= " WHERE fk_categorie = " . $this->id;
         if (!$this->db->query($sql)) {
             $this->error = $this->db->lasterror();
             dol_syslog("Error sql=" . $sql . " " . $this->error, LOG_ERR);
             $error++;
         }
     }
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_member";
         $sql .= " WHERE fk_categorie = " . $this->id;
         if (!$this->db->query($sql)) {
             $this->error = $this->db->lasterror();
             dol_syslog("Error sql=" . $sql . " " . $this->error, LOG_ERR);
             $error++;
         }
     }
     // Link childs to parent
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_association";
         $sql .= " WHERE fk_categorie_mere  = " . $this->id;
         $sql .= " OR fk_categorie_fille = " . $this->id;
         if (!$this->db->query($sql)) {
             $this->error = $this->db->lasterror();
             dol_syslog("Error sql=" . $sql . " " . $this->error, LOG_ERR);
             $error++;
         }
     }
     // Delete category
     if (!$error) {
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie";
         $sql .= " WHERE rowid = " . $this->id;
         if (!$this->db->query($sql)) {
             $this->error = $this->db->lasterror();
             dol_syslog("Error sql=" . $sql . " " . $this->error, LOG_ERR);
             $error++;
         } else {
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('CATEGORY_DELETE', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
                 $this->error = join(',', $this->errors);
             }
             // Fin appel triggers
         }
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:88,代码来源:categorie.class.php

示例11: Interfaces

	define('NOREQUIRESOC', '1');
if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED'))
	define('EVEN_IF_ONLY_LOGIN_ALLOWED', '1');

require_once("../main.inc.php");

// This can happen only with a bookmark or forged url call.
if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser'
		|| $_SESSION["dol_authmode"] == 'http')) {
	die("Disconnection does not work when connection was made in mode " . $_SESSION["dol_authmode"]);
}

// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface = new Interfaces($db);
$result = $interface->run_triggers('USER_LOGOUT', $user, $user, $langs, $conf, $conf->entity);
if ($result < 0) {
	$error++;
}
// Fin appel triggers
// Define url to go after disconnect
$urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"];

// Destroy some cookies
if ($conf->phenix->enabled && $conf->phenix->cookie) {
	// Destroy cookie
	setcookie($conf->phenix->cookie, '', 1, "/");
}

// Destroy object of session
unset($_SESSION['dol_login']);
开发者ID:nrjacker4,项目名称:crm-php,代码行数:31,代码来源:logout.php

示例12: delete

	/**
	 * 		Delete an order
	 *		@return		int		<0 if KO, >0 if OK
	 */
	function delete()
	{
		global $langs,$conf;

		$err = 0;

		$this->db->begin();

		$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =". $this->id ;
		dol_syslog("FournisseurCommande::delete sql=".$sql, LOG_DEBUG);
		if (! $this->db->query($sql) )
		{
			$err++;
		}

		$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE rowid =".$this->id;
		dol_syslog("FournisseurCommande::delete sql=".$sql, LOG_DEBUG);
		if ($resql = $this->db->query($sql) )
		{
			if ($this->db->affected_rows($resql) < 1)
			{
				$err++;
			}
		}
		else
		{
			$err++;
		}

		if ($err == 0)
		{
			// Appel des triggers
			include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
			$interface=new Interfaces($this->db);
			$result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf);
			if ($result < 0) { $error++; $this->errors=$interface->errors; }
			// Fin appel triggers

			dol_syslog("CommandeFournisseur::delete : Success");
			$this->db->commit();
			return 1;
		}
		else
		{
			$this->db->rollback();
			return -1;
		}
	}
开发者ID:remyyounes,项目名称:dolibarr,代码行数:52,代码来源:fournisseur.commande.class.php

示例13: updatePrice


//.........这里部分代码省略.........
     if (empty($this->tva_tx)) {
         $this->tva_tx = 0;
     }
     if (empty($newnpr)) {
         $newnpr = 0;
     }
     // Check parameters
     if ($newvat == '') {
         $newvat = $this->tva_tx;
     }
     if (!empty($newminprice) && $newminprice > $newprice) {
         $this->error = 'ErrorPriceCantBeLowerThanMinPrice';
         return -1;
     }
     if ($newprice != '' || $newprice == 0) {
         if ($newpricebase == 'TTC') {
             $price_ttc = price2num($newprice, 'MU');
             $price = price2num($newprice) / (1 + $newvat / 100);
             $price = price2num($price, 'MU');
             if ($newminprice != '' || $newminprice == 0) {
                 $price_min_ttc = price2num($newminprice, 'MU');
                 $price_min = price2num($newminprice) / (1 + $newvat / 100);
                 $price_min = price2num($price_min, 'MU');
             } else {
                 $price_min = 0;
                 $price_min_ttc = 0;
             }
         } else {
             $price = price2num($newprice, 'MU');
             $price_ttc = $newnpr != 1 ? price2num($newprice) * (1 + $newvat / 100) : $price;
             $price_ttc = price2num($price_ttc, 'MU');
             if ($newminprice != '' || $newminprice == 0) {
                 $price_min = price2num($newminprice, 'MU');
                 $price_min_ttc = price2num($newminprice) * (1 + $newvat / 100);
                 $price_min_ttc = price2num($price_min_ttc, 'MU');
                 //print 'X'.$newminprice.'-'.$price_min;
             } else {
                 $price_min = 0;
                 $price_min_ttc = 0;
             }
         }
         //print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc;
         //Local taxes
         $localtax1 = get_localtax($newvat, 1);
         $localtax2 = get_localtax($newvat, 2);
         if (empty($localtax1)) {
             $localtax1 = 0;
         }
         // If = '' then = 0
         if (empty($localtax2)) {
             $localtax2 = 0;
         }
         // If = '' then = 0
         // Ne pas mettre de quote sur les numeriques decimaux.
         // Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes.
         $sql = "UPDATE " . MAIN_DB_PREFIX . "product SET";
         $sql .= " price_base_type='" . $newpricebase . "',";
         $sql .= " price=" . $price . ",";
         $sql .= " price_ttc=" . $price_ttc . ",";
         $sql .= " price_min=" . $price_min . ",";
         $sql .= " price_min_ttc=" . $price_min_ttc . ",";
         $sql .= " localtax1_tx=" . ($localtax1 >= 0 ? $localtax1 : 'NULL') . ",";
         $sql .= " localtax2_tx=" . ($localtax2 >= 0 ? $localtax2 : 'NULL') . ",";
         $sql .= " tva_tx='" . price2num($newvat) . "',";
         $sql .= " recuperableonly='" . $newnpr . "'";
         $sql .= " WHERE rowid = " . $id;
         dol_syslog(get_class($this) . "update_price sql=" . $sql, LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $this->price = $price;
             $this->price_ttc = $price_ttc;
             $this->price_min = $price_min;
             $this->price_min_ttc = $price_min_ttc;
             $this->price_base_type = $newpricebase;
             $this->tva_tx = $newvat;
             $this->tva_npr = $newnpr;
             //Local taxes
             $this->localtax1_tx = $localtax1;
             $this->localtax2_tx = $localtax2;
             // Price by quantity
             $this->price_by_qty = $newpsq;
             $this->_log_price($user, $level);
             // Save price for level into table product_price
             $this->level = $level;
             // Store level of price edited for trigger
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('PRODUCT_PRICE_MODIFY', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->errors = $interface->errors;
             }
             // Fin appel triggers
         } else {
             dol_print_error($this->db);
         }
     }
     return 1;
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:product.class25..php

示例14: delTimeSpent

    /**
     *  Delete time spent
     *
     *  @param	User	$user        	User that delete
     *  @param  int		$notrigger	    0=launch triggers after, 1=disable triggers
     *  @return	int						<0 if KO, >0 if OK
     */
    function delTimeSpent($user, $notrigger=0)
    {
        global $conf, $langs;

        $error=0;

        $this->db->begin();

        $sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time";
        $sql.= " WHERE rowid = ".$this->timespent_id;

        dol_syslog(get_class($this)."::delTimeSpent sql=".$sql);
        $resql = $this->db->query($sql);
        if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }

        if (! $error)
        {
            if (! $notrigger)
            {
                // Call triggers
                include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
                $interface=new Interfaces($this->db);
                $result=$interface->run_triggers('TASK_TIMESPENT_DELETE',$this,$user,$langs,$conf);
                if ($result < 0) { $error++; $this->errors=$interface->errors; }
                // End call triggers
            }
        }

        if (! $error)
        {
            $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
            $sql.= " SET duration_effective = duration_effective - '".$this->timespent_duration."'";
            $sql.= " WHERE rowid = ".$this->id;

            dol_syslog(get_class($this)."::delTimeSpent sql=".$sql, LOG_DEBUG);
            if ($this->db->query($sql) )
            {
                $result = 0;
            }
            else
            {
                $this->error=$this->db->lasterror();
                dol_syslog(get_class($this)."::addTimeSpent error -3 ".$this->error, LOG_ERR);
                $result = -2;
            }
        }

        // Commit or rollback
        if ($error)
        {
            foreach($this->errors as $errmsg)
            {
                dol_syslog(get_class($this)."::delTimeSpent ".$errmsg, LOG_ERR);
                $this->error.=($this->error?', '.$errmsg:$errmsg);
            }
            $this->db->rollback();
            return -1*$error;
        }
        else
        {
            $this->db->commit();
            return 1;
        }
    }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:71,代码来源:task.class.php

示例15: Interfaces

 /**
  *    Modify the purchase price for a supplier
  *
  *    @param  	int			$qty				Min quantity for which price is valid
  *    @param  	float		$buyprice			Purchase price for the quantity min
  *    @param  	User		$user				Object user user made changes
  *    @param  	string		$price_base_type	HT or TTC
  *    @param  	Societe		$fourn				Supplier
  *    @param  	int			$availability		Product availability
  *    @param	string		$ref_fourn			Supplier ref
  *    @param	float		$tva_tx				VAT rate
  *    @param  	string		$charges			costs affering to product
  *    @param  	float		$remise_percent		Discount  regarding qty (percent)
  *    @param  	float		$remise				Discount  regarding qty (amount)
  *    @param  	int			$newnpr				Set NPR or not
  *    @return	int								<0 if KO, >=0 if OK
  */
 function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0)
 {
     global $conf, $mysoc;
     // Clean parameter
     if (empty($qty)) {
         $qty = 0;
     }
     if (empty($buyprice)) {
         $buyprice = 0;
     }
     if (empty($charges)) {
         $charges = 0;
     }
     if (empty($availability)) {
         $availability = 0;
     }
     if (empty($remise_percent)) {
         $remise_percent = 0;
     }
     if ($price_base_type == 'TTC') {
         //$ttx = get_default_tva($fourn,$mysoc,$this->id);	// We must use the VAT rate defined by user and not calculate it
         $ttx = $tva_tx;
         $buyprice = $buyprice / (1 + $ttx / 100);
     }
     $buyprice = price2num($buyprice, 'MU');
     $charges = price2num($charges, 'MU');
     $qty = price2num($qty);
     $error = 0;
     $unitBuyPrice = price2num($buyprice / $qty, 'MU');
     $unitCharges = price2num($charges / $qty, 'MU');
     $now = dol_now();
     $this->db->begin();
     if ($this->product_fourn_price_id) {
         $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price";
         $sql .= " SET fk_user = " . $user->id . " ,";
         $sql .= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',";
         $sql .= " price = " . price2num($buyprice) . ",";
         $sql .= " quantity = " . $qty . ",";
         $sql .= " remise_percent = " . $remise_percent . ",";
         $sql .= " remise = " . $remise . ",";
         $sql .= " unitprice = " . $unitBuyPrice . ",";
         $sql .= " unitcharges = " . $unitCharges . ",";
         $sql .= " tva_tx = " . $tva_tx . ",";
         $sql .= " fk_availability = " . $availability . ",";
         $sql .= " entity = " . $conf->entity . ",";
         $sql .= " info_bits = " . $newnpr . ",";
         $sql .= " charges = " . $charges;
         $sql .= " WHERE rowid = " . $this->product_fourn_price_id;
         // TODO Add price_base_type and price_ttc
         dol_syslog(get_class($this) . '::update_buyprice sql=' . $sql);
         $resql = $this->db->query($sql);
         if ($resql) {
             // Appel des triggers
             include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
             $interface = new Interfaces($this->db);
             $result = $interface->run_triggers('SUPPLIER_PRODUCT_BUYPRICE_UPDATE', $this, $user, $langs, $conf);
             if ($result < 0) {
                 $error++;
                 $this->error = $interface->errors;
             }
             if (empty($error)) {
                 $this->db->commit();
                 return 0;
             } else {
                 $this->db->rollback();
                 return 1;
             }
         } else {
             $this->error = $this->db->error() . " sql=" . $sql;
             $this->db->rollback();
             return -2;
         }
     } else {
         // Delete price for this quantity
         $sql = "DELETE FROM  " . MAIN_DB_PREFIX . "product_fournisseur_price";
         $sql .= " WHERE fk_soc = " . $fourn->id . " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "' AND quantity = " . $qty . " AND entity = " . $conf->entity;
         dol_syslog(get_class($this) . '::update_buyprice sql=' . $sql);
         $resql = $this->db->query($sql);
         if ($resql) {
             // Add price for this quantity to supplier
             $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
             $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, info_bits, entity)";
             $sql .= " values('" . $this->db->idate($now) . "',";
//.........这里部分代码省略.........
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:fournisseur.product.class.php


注:本文中的Interfaces::run_triggers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。