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']="******"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();
/** * Delete a third party from database and all its dependencies (contacts, rib...) * @param id id of third party to delete */ function delete($id) { global $user,$langs,$conf; require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); dol_syslog("Societe::Delete", LOG_DEBUG); $sqr = 0; // Test if child exists $listtable=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur"); $haschild=0; foreach($listtable as $table) { // Check if third party can be deleted $nb=0; $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table; $sql.= " WHERE fk_soc = " . $id; $resql=$this->db->query($sql); if ($resql) { $obj=$this->db->fetch_object($resql); if ($obj->nb > 0) { $haschild+=$obj->nb; } } else { $this->error .= $this->db->lasterror(); dol_syslog("Societe::Delete erreur -1 ".$this->error, LOG_ERR); return -1; } } if ($haschild > 0) { $this->error="ErrorRecordHasChildren"; return -1; } if ($this->db->begin()) { // Added by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-third-party-deleting.html) // Removing every "categorie" link with this company require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); $static_cat = new Categorie($this->db); $toute_categs = array(); // Fill $toute_categs array with an array of (type => array of ("Categorie" instance)) if ($this->client || $this->prospect) { $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; } } }
/** * 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; }
/** * 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(); return -2; } }
/** * Delete a third party from database and all its dependencies (contacts, rib...) * * @param int $id Id of third party to delete * @return int <0 if KO, 0 if nothing done, >0 if OK */ function delete($id) { global $user, $langs, $conf; require_once(DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"); dol_syslog(get_class($this) . "::delete", LOG_DEBUG); $error = 0; // Test if child exists //$objectisused = $this->isObjectUsed($this->rowid); // TODO A reactivier if (empty($objectisused)) { require_once(DOL_DOCUMENT_ROOT . "/categories/class/categorie.class.php"); $static_cat = new Categorie($this->db); $toute_categs = array(); // Fill $toute_categs array with an array of (type => array of ("Categorie" instance)) if ($this->client || $this->prospect) { $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); } } 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; } } }
/** * 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; } }
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");
/** * 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; } }
/** * 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; } }
/** * 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; } }
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']);
/** * 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; } }
/** * Modify price of a product/Service * * @param double $newprice New price * @param string $newpricebase HT or TTC * @param User $user Object user that make change * @param double $newvat New VAT Rate * @param double $newminprice New price min * @param int $level 0=standard, >0 = level if multilevel prices * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT * @param int $newpsq 1 if it has price by quantity * @return int <0 if KO, >0 if OK */ function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = '', $level = 0, $newnpr = 0, $newpsq = 0) { global $conf, $langs; $id = $this->id; dol_syslog(get_class($this) . "update_price id=" . $id . " newprice=" . $newprice . " newpricebase=" . $newpricebase . " newminprice=" . $newminprice . " level=" . $level . " npr=" . $newnpr); // Clean parameters 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; }
/** * 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; } }
/** * 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 = "******" ,"; $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) . "',"; $sql .= " " . $this->id . ","; $sql .= " " . $fourn->id . ","; $sql .= " '" . $this->db->escape($ref_fourn) . "',"; $sql .= " " . $user->id . ","; $sql .= " " . $buyprice . ","; $sql .= " " . $qty . ","; $sql .= " " . $remise_percent . ","; $sql .= " " . $remise . ","; $sql .= " " . $unitBuyPrice . ","; $sql .= " " . $tva_tx . ","; $sql .= " " . $charges . ","; $sql .= " " . $unitCharges . ","; $sql .= " " . $availability . ","; $sql .= " " . $newnpr . ","; $sql .= $conf->entity; $sql .= ")"; dol_syslog(get_class($this) . "::update_buyprice sql=" . $sql); if (!$this->db->query($sql)) { $error++; } /*if (! $error) { // Ajoute modif dans table log $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price_log("; $sql.= "datec, fk_product_fournisseur,fk_user,price,quantity)"; $sql.= "values('".$this->db->idate($now)."',"; $sql.= " ".$this->product_fourn_id.","; $sql.= " ".$user->id.","; $sql.= " ".price2num($buyprice).","; $sql.= " ".$qty; $sql.=")"; $resql=$this->db->query($sql); if (! $resql) { $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('SUPPLIER_PRODUCT_BUYPRICE_CREATE', $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 { $this->error = $this->db->error() . " sql=" . $sql; $this->db->rollback(); return -1; } } }
/** * Delete a product from database (if not used) * * @param int $id Product id * @return int < 0 if KO, 0 = Not possible, > 0 if OK */ function delete($id) { global $conf,$user,$langs; $error=0; if ($user->rights->produit->supprimer) { $objectisused = $this->isObjectUsed($id); if (empty($objectisused)) { $this->db->begin(); if (! $error) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('PRODUCT_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } // Delete all child tables $elements = array('product_fournisseur_price','product_price','product_lang','categorie_product'); foreach($elements as $table) { if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; $sql.= " WHERE fk_product = ".$id; dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG); $result = $this->db->query($sql); if (! $result) { $error++; $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR); } } } // Delete product if (! $error) { $sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product"; $sqlz.= " WHERE rowid = ".$id; dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG); $resultz = $this->db->query($sqlz); if ( ! $resultz ) { $error++; $this->error = $this->db->lasterror(); dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR); } } if (! $error) { // We remove directory $ref = dol_sanitizeFileName($this->ref); if ($conf->product->dir_output) { $dir = $conf->product->dir_output . "/" . $ref; if (file_exists($dir)) { $res=@dol_delete_dir_recursive($dir); if (! $res) { $this->error='ErrorFailToDeleteDir'; $error++; } } } } if (! $error) { $this->db->commit(); return 1; } else { $this->db->rollback(); return -$error; } } else { $this->error = "ErrorRecordHasChildren"; return 0; } } return 0; }
/** * Delete line in database * * @return int <0 if KO, >0 if OK */ function delete() { global $conf, $langs, $user; $error = 0; $this->db->begin(); $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet WHERE rowid = " . $this->rowid; dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG); if ($this->db->query($sql)) { // Appel des triggers include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"; $interface = new Interfaces($this->db); $result = $interface->run_triggers('LINEBILL_DELETE', $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() . " sql=" . $sql; dol_syslog(get_class($this) . "::delete Error " . $this->error, LOG_ERR); $this->db->rollback(); return -1; } }
// resArray was built from a string like that // TOKEN=EC%2d1NJ057703V9359028&TIMESTAMP=2010%2d11%2d01T11%3a40%3a13Z&CORRELATIONID=1efa8c6a36bd8&ACK=Success&VERSION=56&BUILD=1553277&TRANSACTIONID=9B994597K9921420R&TRANSACTIONTYPE=expresscheckout&PAYMENTTYPE=instant&ORDERTIME=2010%2d11%2d01T11%3a40%3a12Z&AMT=155%2e57&FEEAMT=5%2e54&TAXAMT=0%2e00&CURRENCYCODE=EUR&PAYMENTSTATUS=Completed&PENDINGREASON=None&REASONCODE=None $PAYMENTSTATUS = urldecode($resArray["PAYMENTSTATUS"]); // Should contains 'Completed' $TRANSACTIONID = urldecode($resArray["TRANSACTIONID"]); $TAXAMT = urldecode($resArray["TAXAMT"]); $NOTE = urldecode($resArray["NOTE"]); print $langs->trans("YourPaymentHasBeenRecorded") . "<br>\n"; print $langs->trans("ThisIsTransactionId", $TRANSACTIONID) . "<br><br>\n"; if (!empty($conf->global->PAYPAL_MESSAGE_OK)) { print $conf->global->PAYPAL_MESSAGE_OK; } // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($db); $result = $interface->run_triggers('PAYPAL_PAYMENT_OK', $object, $user, $langs, $conf); if ($result < 0) { $error++; $errors = $interface->errors; } // Fin appel triggers // Send an email if (!empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) { $sendto = $conf->global->PAYPAL_PAYONLINE_SENDEMAIL; $from = $conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT; // This is to use external domain name found into config file //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current $urlback = $_SERVER["REQUEST_URI"];
/** * Create payment in database * * @param User $user Object of creating user * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more * @return int id of created payment, < 0 if error */ function create($user, $closepaidinvoices = 0) { global $langs, $conf; $error = 0; // Clean parameters $this->total = 0; foreach ($this->amounts as $key => $value) { $value = price2num($value); $val = round($value, 2); $this->amounts[$key] = $val; $this->total += $val; } $this->total = price2num($this->total); $this->db->begin(); if ($this->total != 0) { $now = dol_now(); $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'paiementfourn ('; $sql .= 'datec, datep, amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)'; $sql .= ' VALUES (' . $this->db->idate($now) . ','; $sql .= " " . $this->db->idate($this->datepaye) . ", '" . $this->total . "', " . $this->paiementid . ", '" . $this->num_paiement . "', '" . $this->db->escape($this->note) . "', " . $user->id . ", 0)"; dol_syslog("PaiementFourn::create sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . 'paiementfourn'); // Insere tableau des montants / factures foreach ($this->amounts as $key => $amount) { $facid = $key; if (is_numeric($amount) && $amount != 0) { $amount = price2num($amount); $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'paiementfourn_facturefourn (fk_facturefourn, fk_paiementfourn, amount)'; $sql .= ' VALUES (' . $facid . ',' . $this->id . ',\'' . $amount . '\')'; $resql = $this->db->query($sql); if ($resql) { // If we want to closed payed invoices if ($closepaidinvoices) { $invoice = new FactureFournisseur($this->db); $invoice->fetch($facid); $paiement = $invoice->getSommePaiement(); //$creditnotes=$invoice->getSumCreditNotesUsed(); $creditnotes = 0; //$deposits=$invoice->getSumDepositsUsed(); $deposits = 0; $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { $result = $invoice->set_paid($user, '', ''); } else { dol_syslog("Remain to pay for invoice " . $facid . " not null. We do nothing."); } } } else { dol_syslog('Paiement::Create Erreur INSERT dans paiement_facture ' . $facid); $error++; } } else { dol_syslog('PaiementFourn::Create Montant non numerique', 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('PAYMENT_SUPPLIER_CREATE', $this, $user, $langs, $conf); if ($result < 0) { $error++; $this->errors = $interface->errors; } // Fin appel triggers } } else { $this->error = $this->db->lasterror(); dol_syslog('PaiementFourn::Create Error ' . $this->error, LOG_ERR); $error++; } } else { $this->error = "ErrorTotalIsNull"; dol_syslog('PaiementFourn::Create Error ' . $this->error, LOG_ERR); $error++; } if ($this->total != 0 && $error == 0) { $this->db->commit(); dol_syslog('PaiementFourn::Create Ok Total = ' . $this->total); return $this->id; } else { $this->db->rollback(); return -1; } }
/** * Update propal line object into DB * * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers * @return int <0 if ko, >0 if ok */ function update($notrigger = 0) { global $conf, $langs, $user; $error = 0; // 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->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->special_code)) { $this->special_code = 0; } if (empty($this->fk_parent_line)) { $this->fk_parent_line = 0; } if (empty($this->pa_ht)) { $this->pa_ht = 0; } // si prix d'achat non renseign� et utilis� pour calcul des marges alors prix achat = prix vente (idem pour remises) if ($this->pa_ht == 0) { if ($this->subprice < 0 || $conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1) { $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); } } $this->db->begin(); // Mise a jour ligne en base $sql = "UPDATE " . MAIN_DB_PREFIX . "propaldet 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 $sql .= " , info_bits='" . $this->info_bits . "'"; 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 .= " , fk_product_fournisseur_price='" . $this->fk_fournprice . "'"; $sql .= " , buy_price_ht='" . price2num($this->pa_ht) . "'"; $sql .= " , info_bits=" . $this->info_bits; if (strlen($this->special_code)) { $sql .= " , special_code=" . $this->special_code; } $sql .= " , fk_parent_line=" . ($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); if (!empty($this->rang)) { $sql .= ", rang=" . $this->rang; } $sql .= " WHERE rowid = " . $this->rowid; dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $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('LINEPROPAL_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(get_class($this) . "::update Error " . $this->error, LOG_ERR); $this->db->rollback(); return -2; } }
} else { $result = $mailfile->sendfile(); if ($result) { $_SESSION['mesg'] = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); $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('SHIPPING_SENTBYMAIL', $object, $user, $langs, $conf); if ($result < 0) { $error++; $this->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");
// Initialisation of datas $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to a contact/address $object->actiontypecode = $actiontypecode; $object->actionmsg = $actionmsg; // Long text $object->actionmsg2 = $actionmsg2; // Short text $object->fk_element = $object->id; $object->elementtype = $object->element; // Call of triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($db); $result = $interface->run_triggers($trigger_name, $object, $user, $langs, $conf); if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call of triggers if ($error) { dol_print_error($db); } else { // Redirect here // This avoid sending mail twice if going out and then back to page $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); setEventMessages($mesg, null, 'mesgs'); if ($conf->dolimail->enabled) { header('Location: ' . $_SERVER["PHP_SELF"] . '?' . ($paramname ? $paramname : 'id') . '=' . $object->id . '&' . ($paramname2 ? $paramname2 : 'mid') . '=' . $parm2val); } else {
/** * Efface le contact de la base * @param notrigger Disable all trigger * @return int <0 if KO, >0 if OK */ function delete($notrigger=0) { global $conf, $langs, $user; $error=0; $this->old_name = $obj->name; $this->old_firstname = $obj->firstname; $this->db->begin(); if (! $error) { // Get all rowid of element_contact linked to a type that is link to llx_socpeople $sql = "SELECT ec.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,"; $sql.= " ".MAIN_DB_PREFIX."c_type_contact tc"; $sql.= " WHERE ec.fk_socpeople=".$this->id; $sql.= " AND ec.fk_c_type_contact=tc.rowid"; $sql.= " AND tc.source='external'"; dol_syslog("Contact::delete sql=".$sql); $resql = $this->db->query($sql); if ($resql) { $num=$this->db->num_rows($resql); $i=0; while ($i < $num && ! $error) { $obj = $this->db->fetch_object($resql); $sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sqldel.=" WHERE rowid = ".$obj->rowid; dol_syslog("Contact::delete sql=".$sqldel); $result = $this->db->query($sqldel); if (! $result) { $error++; $this->error=$this->db->error().' sql='.$sqldel; } $i++; } } else { $error++; $this->error=$this->db->error().' sql='.$sql; } } if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople"; $sql .= " WHERE rowid=".$this->id; dol_syslog("Contact::delete sql=".$sql); $result = $this->db->query($sql); if (! $result) { $error++; $this->error=$this->db->error().' sql='.$sql; } } if (! $error && ! $notrigger) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers if ($error) $this->error=join(',',$this->errors); } if (! $error) { $this->db->commit(); return 1; } else { $this->db->rollback(); return -1; } }
public function setAccountancyCode($type, $value) { global $user, $langs, $conf; $this->db->begin(); if ($type == 'buy') { $field = 'accountancy_code_buy'; } elseif ($type == 'sell') { $field = 'accountancy_code_sell'; } else { return -1; } $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET "; $sql .= "{$field} = '" . $this->db->escape($value) . "'"; $sql .= " WHERE rowid = " . $this->id; dol_syslog(get_class($this) . "::" . __FUNCTION__ . " sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { // Call triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($this->db); $result = $interface->run_triggers('PRODUCT_MODIFY', $this, $user, $langs, $conf); if ($result < 0) { $this->errors = $interface->errors; $this->db->rollback(); return -1; } // End call triggers $this->{$field} = $value; $this->db->commit(); return 1; } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return -1; } }
/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function blockRelated($parameters, &$object, &$action, $hookmanager, $moreStyle = '') { global $langs, $db, $user, $conf, $related_link_added; $error = 0; // Error counter //var_dump($objet); define('INC_FROM_DOLIBARR', true); dol_include_once('/related/config.php'); $PDOdb = new TPDOdb(); $langs->load('related@related'); if (GETPOST('action') == 'add_related_link' && !$related_link_added) { $type = GETPOST('type_related_object'); //var_dump($type);exit; if ($type == 'projet') { $type = 'project'; } else { if ($type == 'invoice') { $type = 'facture'; } else { if ($type == 'company') { $type = 'societe'; } else { if ($type == 'facture_fournisseur') { $type = 'invoice_supplier'; } else { if ($type == 'commande_fournisseur') { $type = 'order_supplier'; } } } } } $res = $object->add_object_linked($type, GETPOST('id_related_object')); $object->fetchObjectLinked(); if (empty($res)) { setEventMessage($langs->trans('RelationCantBeAdded'), 'errors'); } else { $related_link_added = true; global $langs, $conf; dol_include_once('/core/class/interfaces.class.php'); $interface = new Interfaces($db); $object->id_related_object = GETPOST('id_related_object'); $object->type_related_object = $type; $result = $interface->run_triggers('RELATED_ADD_LINK', $object, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { $this->errors = array_merge($this->errors, $interface->errors); } else { $this->errors = $interface->errors; } } setEventMessage($langs->trans('RelationAdded')); } } elseif (GETPOST('action') == 'delete_related_link') { $idLink = GETPOST('id_link'); if ($idLink) { $PDOdb->Execute("DELETE FROM " . MAIN_DB_PREFIX . "element_element WHERE rowid = " . $idLink); $object->fetchObjectLinked(); } } else { //var_dump($object); if (empty($object->linkedObjects)) { $object->fetchObjectLinked(); } } //var_dump($object->linkedObjectsIds); ?> <div class="blockrelated_content" style="<?php echo $moreStyle; ?> "> <form name="formLinkObj" action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <input type="hidden" name="action" value="add_related_link" /> <input type="hidden" name="id" value="<?php echo GETPOST('id'); ?> " /> <input type="hidden" name="facid" value="<?php echo GETPOST('facid'); ?> " /> <br> <div class="titre"><?php echo $langs->trans('ElementToLink'); ?> </div> <input type="hidden" id="id_related_object" name="id_related_object" value="" /> <input type="hidden" id="type_related_object" name="type_related_object" value="" /> <table class="noborder allwidth"> <tr class="liste_titre"> <td><?php echo $langs->trans("Ref"); ?> <input type="text" id="add_related_object" name="add_related_object" value="" class="flat" /> <input type="submit" id="bt_add_related_object" name="bt_add_related_object" class="button" value="<?php echo $langs->trans('AddRelated'); ?> " style="display:none" /></td> <td align="center"><?php echo $langs->trans("Date"); ?> </td> <td align="center"><?php echo $langs->trans("Status"); ?> </td> <td align="center"><?php echo $langs->trans("Action"); ?> </td> </tr> <?php $class = 'pair'; foreach ($object->linkedObjectsIds as $objecttype => &$TSubIdObject) { //var_dump($objecttype); if (isset($object->linkedObjects[$objecttype]) && $objecttype != 'societe' && $objecttype != 'product' && $object->element != 'project') { continue; } // on affiche ici que les objects non géré en natif foreach ($TSubIdObject as $id_object) { $date_create = 0; $classname = ucfirst($objecttype); $statut = 'N/A'; if ($objecttype == 'task') { dol_include_once('/projet/class/task.class.php'); } else { if ($objecttype == 'event' || $objecttype == 'action') { dol_include_once('/comm/action/class/actioncomm.class.php'); $classname = 'ActionComm'; } else { if ($objecttype == 'project') { dol_include_once('/projet/class/project.class.php'); } else { if ($objecttype == 'ordre_fabrication') { dol_include_once('/of/class/ordre_fabrication_asset.class.php'); $classname = 'TAssetOf'; $abricot = true; } } } } if (!class_exists($classname)) { $link = 'CantInstanciateClass ' . $classname; } else { if (!empty($abricot)) { if (empty($PDOdb)) { $PDOdb = new TPDOdb(); } $subobject = new $classname(); $subobject->load($PDOdb, $id_object); if (method_exists($subobject, 'getNomUrl')) { $link = $subobject->getNomUrl(1); } else { $link = $id_object . '/' . $classname; } $class = $class == 'impair' ? 'pair' : 'impair'; $date_create = $subobject->date_cre; if (method_exists($subobject, 'getLibStatut')) { $statut = $subobject->getLibStatut(3); } } else { $subobject = new $classname($db); $subobject->fetch($id_object); if (method_exists($subobject, 'getNomUrl')) { $link = $subobject->getNomUrl(1); } else { $link = $id_object . '/' . $classname; } $class = $class == 'impair' ? 'pair' : 'impair'; if (!empty($subobject->date_creation)) { $date_create = $subobject->date_creation; } if (empty($date_create) && !empty($subobject->date_create)) { $date_create = $subobject->date_create; } if (empty($date_create) && !empty($subobject->date_c)) { $date_create = $subobject->date_c; } if (method_exists($subobject, 'getLibStatut')) { $statut = $subobject->getLibStatut(3); } } } $Tids = TRequeteCore::get_id_from_what_you_want($PDOdb, MAIN_DB_PREFIX . "element_element", array('fk_source' => $id_object, 'fk_target' => $object->id, 'sourcetype' => $objecttype, 'targettype' => $object->element)); ?> <tr class="<?php echo $class; ?> "> <td><?php echo $link; ?> </td> <td align="center"><?php echo !empty($date_create) ? dol_print_date($date_create, 'day') : ''; ?> </td> <td align="center"><?php echo $statut; ?> </td> <td align="center"><a href="?id=<?php echo $object->id; ?> &action=delete_related_link&id_link=<?php echo $Tids[0]; ?> "><?php print img_picto($langs->trans("Delete"), 'delete.png'); ?> </a></td> </tr> <?php } } ?> </table> </form> </div> <script type="text/javascript"> $(document).ready(function() { $('#add_related_object').autocomplete({ source: function( request, response ) { $.ajax({ url: "<?php echo dol_buildpath('/related/script/interface.php', 1); ?> ", dataType: "json", data: { key: request.term ,get:'search' } ,success: function( data ) { var c = []; $.each(data, function (i, cat) { var first = true; $.each(cat, function(j, label) { if(first) { c.push({value:i, label:i, object:'title'}); first = false; } c.push({ value: j, label:' '+label, object:i}); }); }); response(c); } }); }, minLength: 1, select: function( event, ui ) { if(ui.item.object == 'title') return false; else { $('#id_related_object').val(ui.item.value); $('#add_related_object').val(ui.item.label.trim()); $('#type_related_object').val(ui.item.object); $('#bt_add_related_object').css('display','inline'); return false; } }, open: function( event, ui ) { $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); $( "#add_related_object" ).autocomplete( "instance" )._renderItem = function( ul, item ) { $li = $( "<li />" ) .attr( "data-value", item.value ) .append( item.label ) .appendTo( ul ); if(item.object=="title") $li.css("font-weight","bold"); return $li; }; var blockrelated = $('div.tabsAction .blockrelated_content'); if (blockrelated.length == 1) { if ($('.blockrelated_content').length > 1) { blockrelated.remove(); } else { $('div.tabsAction').after(blockrelated.clone()); blockrelated.remove(); } } }); </script> <?php if (!$error) { return 0; // or return 1 to replace standard code } else { $this->errors[] = 'Cant link related'; return -1; } }
$result = $mailfile->sendfile(); if ($result) { $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); 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('FICHINTER_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");
/** * Delete a link to resource line * TODO: move into commonobject class * * @param int $rowid Id of resource line to delete * @param int $element element name (for trigger) TODO: use $this->element into commonobject class * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ function delete_resource($rowid, $element, $notrigger = 0) { global $user, $langs, $conf; $error = 0; $sql = "DELETE FROM " . MAIN_DB_PREFIX . "element_resources"; $sql .= " WHERE rowid =" . $rowid; dol_syslog(get_class($this) . "::delete_resource sql=" . $sql); if ($this->db->query($sql)) { if (!$notrigger) { // Call triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($this->db); $result = $interface->run_triggers(strtoupper($element) . '_DELETE_RESOURCE', $this, $user, $langs, $conf); if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call triggers } return 1; } else { $this->error = $this->db->lasterror(); dol_syslog(get_class($this) . "::delete_resource error=" . $this->error, LOG_ERR); return -1; } }
/** * Create a document onto disk according to template module. * * @param DoliDB $db Database handler * @param Object $object Object invoice * @param string $modele Force template to use ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref * @return int <0 if KO, >0 if OK */ function lcr_pdf_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, &$TtoGenerate) { global $conf, $user, $langs; $langs->load("bills"); $error = 0; // Increase limit for PDF build $err = error_reporting(); error_reporting(0); @set_time_limit(120); error_reporting($err); $srctemplatepath = ''; // Positionne le modele sur le nom du modele a utiliser if (!dol_strlen($modele)) { if (!empty($conf->global->FACTURE_ADDON_PDF)) { $modele = $conf->global->FACTURE_ADDON_PDF; } else { $modele = 'crabe'; } } // If selected modele is a filename template (then $modele="modelname:filename") $tmp = explode(':', $modele, 2); if (!empty($tmp[1])) { $modele = $tmp[0]; $srctemplatepath = $tmp[1]; } // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array('/'); if (is_array($conf->modules_parts['models'])) { $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); } foreach ($dirmodels as $reldir) { foreach (array('doc', 'pdf') as $prefix) { $file = $prefix . "_" . $modele . ".modules.php"; // On verifie l'emplacement du modele //echo $reldir."core/modules/facture/doc/".$file.'<br>'; $file = dol_buildpath($reldir . "core/modules/lcr/doc/" . $file, 0); if (file_exists($file)) { $filefound = 1; $classname = $prefix . '_' . $modele; break; } } if ($filefound) { break; } } // Charge le modele if ($filefound) { require_once $file; $obj = new $classname($db); // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($db); $result = $interface->run_triggers('BEFORE_BILL_BUILDDOC', $object, $user, $langs, $conf); if ($result < 0) { $error++; $errors = $interface->errors; } // Fin appel triggers // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output = $outputlangs->charset_output; if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $TtoGenerate) > 0) { $outputlangs->charset_output = $sav_charset_output; // We delete old preview require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; //dol_delete_preview($object); // Success in building document. We build meta file. dol_meta_create($object); // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface = new Interfaces($db); $result = $interface->run_triggers('BILL_BUILDDOC', $object, $user, $langs, $conf); if ($result < 0) { $error++; $errors = $interface->errors; } // Fin appel triggers return 1; } else { $outputlangs->charset_output = $sav_charset_output; dol_print_error($db, "lcr_pdf_create Error: " . $obj->error); return -1; } } else { dol_print_error('', $langs->trans("Error") . " " . $langs->trans("ErrorFileDoesNotExists", $file)); return -1; } }
// Initialisation donnees $object->socid = $sendtosocid; // To link to a company $object->sendtoid = $sendtoid; // To link to a contact/address $object->actiontypecode = $actiontypecode; $object->actionmsg = $actionmsg; // Long text $object->actionmsg2 = $actionmsg2; // Short text $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('COMPANY_SENTBYMAIL', $object, $user, $langs, $conf); if ($result < 0) { $error++; $this->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 $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)); setEventMessage($mesg); header('Location: ' . $_SERVER["PHP_SELF"] . '?' . ($paramname ? $paramname : 'id') . '=' . $object->id); exit; }
$_SESSION["dol_dst_first"] = isset($dol_dst_first) ? $dol_dst_first : ''; $_SESSION["dol_dst_second"] = isset($dol_dst_second) ? $dol_dst_second : ''; $_SESSION["dol_screenwidth"] = isset($dol_screenwidth) ? $dol_screenwidth : ''; $_SESSION["dol_screenheight"] = isset($dol_screenheight) ? $dol_screenheight : ''; $_SESSION["dol_company"] = $conf->global->MAIN_INFO_SOCIETE_NOM; $_SESSION["dol_entity"] = $conf->entity; dol_syslog("This is a new started user session. _SESSION['dol_login']="******"dol_login"] . ' Session id=' . session_id()); $db->begin(); $user->update_last_login_date(); // 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, $_POST["entity"]); if ($result < 0) { $error++; } // End call triggers if ($error) { $db->rollback(); session_destroy(); dol_print_error($db, 'Error in some triggers on action USER_LOGIN', LOG_ERR); exit; } else { $db->commit(); } // Create entity cookie, just used for login page