function beforePDFCreation($parameters, &$object, &$action, $hookmanager) { if ($object->element == 'facture') { if (isset($object->thirdparty)) { $societe =& $object->thirdparty; } else { dol_include_once('/societe/class/societe.class.php'); $societe = new Societe($db); $societe->fetch($object->socid); } if (!empty($societe->id)) { global $db, $conf; if (!empty($societe->array_options['options_fk_soc_factor']) && $societe->array_options['options_factor_suivi'] == 1) { define('INC_FROM_DOLIBARR', true); dol_include_once('/factor/config.php'); dol_include_once('/factor/class/factor.class.php'); $PDOdb = new TPDOdb(); $factor = new TFactor(); $factor->loadBy($PDOdb, $societe->array_options['options_fk_soc_factor'], 'fk_soc'); if (!empty($factor->mention)) { if (strpos($object->note_public, $factor->mention) === false) { $object->note_public = $factor->mention . (!empty($object->note_public) ? "\n\n" . $object->note_public : ''); $r = $object->update_note($object->note_public, '_public'); } } } } } }
static function getRefByObject(&$object) { global $db; $ref = ''; if ($object->element == 'societe' && !empty($object->code_client)) { $ref = $object->code_client; } else { if ($object->element == 'societe') { $ref = $object->name; } else { if ($object->element == 'contact') { dol_include_once('/societe/class/societe.class.php'); $soc = new Societe($db); $soc->fetch($object->socid); $ref = trim((!empty($soc->code_client) ? $soc->code_client : $soc->name) . '_' . $object->lastname); } else { if ($object->element == 'user' && !empty($object->login)) { $ref = $object->login; } elseif (!empty($object->ref)) { $ref = $object->ref; } } } } return $ref; }
/** * Get object from id or ref and save it into this->object * * @param int $id Object id * @param ref $ref Object ref * @return object Object loaded */ protected function getObject($id,$ref='') { $ret = $this->getInstanceDao(); $object = new Societe($this->db); if (! empty($id) || ! empty($ref)) $object->fetch($id,$ref); $this->object = $object; }
/** * Add a product into cart * * @return void */ public function ajoutArticle() { global $conf, $db, $mysoc; $thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY']; $societe = new Societe($db); $societe->fetch($thirdpartyid); $product = new Product($db); $product->fetch($this->id); $sql = "SELECT taux"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva"; $sql .= " WHERE rowid = " . $this->tva(); dol_syslog("ajoutArticle", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); $vat_rate = $obj->taux; //var_dump($vat_rate);exit; } else { dol_print_error($db); } // Define part of HT, VAT, TTC $resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $vat_rate, 0, 0, 0, 'HT', 0, $product->type, $mysoc); // Calcul du total ht sans remise $total_ht = $resultarray[0]; $total_vat = $resultarray[1]; $total_ttc = $resultarray[2]; // Calcul du montant de la remise if ($this->remisePercent()) { $remise_percent = $this->remisePercent(); } else { $remise_percent = 0; } $montant_remise_ht = $resultarray[6] - $resultarray[0]; $this->montantRemise($montant_remise_ht); $newcartarray = $_SESSION['poscart']; $i = count($newcartarray); $newcartarray[$i]['id'] = $i; $newcartarray[$i]['ref'] = $product->ref; $newcartarray[$i]['label'] = $product->label; $newcartarray[$i]['price'] = $product->price; $newcartarray[$i]['price_ttc'] = $product->price_ttc; if (!empty($conf->global->PRODUIT_MULTIPRICES)) { if (isset($product->multiprices[$societe->price_level])) { $newcartarray[$i]['price'] = $product->multiprices[$societe->price_level]; $newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level]; } } $newcartarray[$i]['fk_article'] = $this->id; $newcartarray[$i]['qte'] = $this->qte(); $newcartarray[$i]['fk_tva'] = $this->tva(); $newcartarray[$i]['remise_percent'] = $remise_percent; $newcartarray[$i]['remise'] = price2num($montant_remise_ht); $newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT'); $newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT'); $_SESSION['poscart'] = $newcartarray; $this->raz(); }
function _get_company_object(&$TRender) { global $db, $conf, $langs, $user; dol_include_once('/societe/class/societe.class.php'); foreach ($TRender as $fk_soc => &$line) { $s = new Societe($db); $s->fetch($fk_soc); $line['client'] = $s->name; } }
/** * Delete thirdparty * * @param int $id Thirparty ID * @return type * * @url DELETE thirdparty/{id} */ function delete($id) { if (!DolibarrApiAccess::$user->rights->societe->supprimer) { throw new RestException(401); } $result = $this->company->fetch($id); if (!$result) { throw new RestException(404, 'Thirdparty not found'); } if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } return $this->company->delete($id); }
static function getRemise(&$PDOdb, $type, $total, $zip = '', $fk_shipment_mode = 0, $fk_soc = 0) { global $db, $conf; if (!empty($conf->global->REMISE_USE_THIRDPARTY_DISCOUNT) && !empty($fk_soc)) { dol_include_once('/societe/class/societe.class.php'); $s = new Societe($db); $s->fetch($fk_soc); return $s->array_options['options_remsup']; } $TRemise = TRemise::getAll($PDOdb, $type, true, !empty($zip), !empty($fk_shipment_mode)); $remise_used = 0; $find = false; if (!empty($TRemise)) { foreach ($TRemise as &$remise) { if ($type === 'WEIGHT' && $total >= $remise['palier'] && ($remise['remise'] > $remise_used || empty($remise_used))) { if (!empty($zip) && !empty($remise['zip']) && strpos($zip, $remise['zip']) === 0) { $remise_used = $remise['remise']; $find = true; break; } else { if (empty($zip) && empty($remise['zip'])) { // pas de remise associée au code poste trouvé avant $find = true; $remise_used = $remise['remise']; break; } } } else { if ($type === 'AMOUNT') { if ($total >= $remise['palier'] && ($remise['remise'] > $remise_used || empty($remise_used))) { $remise_used = $remise['remise']; $find = true; } } } } } if (!$find && !empty($zip)) { return TRemise::getRemise($PDOdb, $type, $total); } else { return $remise_used; } }
function generateCSV() { global $db, $conf; $TFactRef = $_REQUEST['toGenerate']; // Création et attribution droits fichier $dir = $conf->lcr->dir_output; $filename = 'lcr_' . date('YmdHis') . '.csv'; $f = fopen($dir . '/' . $filename, 'w+'); chmod($dir . '/' . $filename, 0777); $TTitle = array('Code client', 'Raison sociale', 'Adresse 1', 'Adresse 2', 'Code postal', 'Ville', 'Téléphone', 'Référence', 'SIREN', 'RIB', 'Agence', 'Montant', 'Monnaie', 'Accepté', 'Référence', 'Date de création', 'Date d\'échéance'); fputcsv($f, $TTitle, ';'); $fact = new Facture($db); $s = new Societe($db); foreach ($TFactRef as $ref_fact) { if ($fact->fetch('', $ref_fact) > 0 && $s->fetch($fact->socid) > 0) { $rib = $s->get_all_rib(); fputcsv($f, array($s->code_client, $s->name, $s->address, '', $s->zip, $s->town, $s->phone, $ref_fact, $s->idprof1, $rib[0]->iban, '', price($fact->total_ttc), 'E', 1, $ref_fact, date('d/m/Y', $fact->date), date('d/m/Y', $fact->date_lim_reglement)), ';'); } } fclose($f); }
$result = $delivery->fetch($_GET["id"]); $delivery->fetch_thirdparty(); $expedition=new Expedition($db); $result = $expedition->fetch($delivery->origin_id); $typeobject = $expedition->origin; if ($delivery->origin_id) { $delivery->fetch_origin(); } if ( $delivery->id > 0) { $soc = new Societe($db); $soc->fetch($delivery->socid); $head=delivery_prepare_head($delivery); dol_fiche_head($head, 'delivery', $langs->trans("Sending"), 0, 'sending'); /* * Confirmation de la suppression * */ if ($_GET["action"] == 'delete') { $expedition_id = $_GET["expid"]; $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?id='.$delivery->id.'&expid='.$expedition_id,$langs->trans("DeleteDeliveryReceipt"),$langs->trans("DeleteDeliveryReceiptConfirm",$delivery->ref),'confirm_delete','','',1); if ($ret == 'html') print '<br>'; }
* \brief Tab for notes on third party * \ingroup societe */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; $action = GETPOST('action'); $langs->load("companies"); // Security check $id = GETPOST('id') ? GETPOST('id', 'int') : GETPOST('socid', 'int'); if ($user->societe_id) { $id = $user->societe_id; } $result = restrictedArea($user, 'societe', $id, '&societe'); $object = new Societe($db); if ($id > 0) { $object->fetch($id); } $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php /* * Actions */ include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once /* * View */ $form = new Form($db); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $langs->trans("ThirdParty") . ' - ' . $langs->trans("Notes"), $help_url); if ($id > 0) {
$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ', p.ref DESC'; $nbtotalofrecords = 0; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); } //print $sql; $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { $objectstatic = new Propal($db); $userstatic = new User($db); $num = $db->num_rows($result); if ($socid) { $soc = new Societe($db); $soc->fetch($socid); } $param = '&socid=' . $socid . '&viewstatut=' . $viewstatut; if ($month) { $param .= '&month=' . $month; } if ($year) { $param .= '&year=' . $year; } if ($search_ref) { $param .= '&search_ref=' . $search_ref; } if ($search_refcustomer) { $param .= '&search_refcustomer=' . $search_refcustomer; } if ($search_societe) {
* (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; include_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; if (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) { $company = new Societe($db); $company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]); $companyLink = $company->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) { $bankcash = new Account($db); $bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]); $bankcash->label = $bankcash->ref; $bankcashLink = $bankcash->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) { $bankcb = new Account($db); $bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]); $bankcbLink = $bankcb->getNomUrl(1); } if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) { $bankcheque = new Account($db);
// Remove element from category if ($id > 0 && $removeelem > 0) { if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $tmpobject = new Product($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'product'; } else { if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'fournisseur'; } else { if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'societe'; } else { if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'member'; } else { if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; } }
/* * Show object in view mode */ $result = $object->fetch($id, $ref); if ($result <= 0) { dol_print_error($db, $object->error); exit; } // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); if ($user->societe_id > 0 && $user->societe_id != $object->socid) { accessforbidden('', 0); } $result = $object->fetch_thirdparty(); $soc = new Societe($db); $result = $soc->fetch($object->socid); if ($result < 0) { dol_print_error($db); } $selleruserevenustamp = $mysoc->useRevenueStamp(); $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); // print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." // selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); if ($object->paye) {
print '</div>'; } else { /* * Confirmation de la suppression du deplacement */ if ($_GET["action"] == 'delete') { $ret=$html->form_confirm("fiche.php?id=".$id,$langs->trans("DeleteTrip"),$langs->trans("ConfirmDeleteTrip"),"confirm_delete"); if ($ret == 'html') print '<br>'; } $soc = new Societe($db); if ($deplacement->socid) $soc->fetch($deplacement->socid); print '<table class="border" width="100%">'; // Ref print "<tr>"; print '<td width="20%">'.$langs->trans("Ref").'</td><td>'; print $html->showrefnav($deplacement,'id','',1,'rowid','ref',''); print '</td></tr>'; // Type print '<tr><td>'.$langs->trans("Type").'</td><td>'.$langs->trans($deplacement->type).'</td></tr>'; // Who print '<tr><td>'.$langs->trans("Person").'</td><td>'; $userfee=new User($db);
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; print ' '; print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">'; print '</div>'; print '</form>'; print '</div>'; } else { /* * Confirm delete trip */ if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"] . "?id=" . $id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); } $soc = new Societe($db); if ($object->socid) { $soc->fetch($object->socid); } print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/compta/deplacement/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td width="25%">' . $langs->trans("Ref") . '</td><td>'; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); print '</td></tr>'; $form->load_cache_types_fees(); // Type print '<tr><td>'; print $form->editfieldkey("Type", 'type', $langs->trans($object->type), $object, $conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer, 'select:types_fees'); print '</td><td>'; print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer, 'select:types_fees'); print '</td></tr>'; // Who
} print '</td></tr>'; // Realised by if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) { print '<tr><td class="nowrap">' . $langs->trans("ActionDoneBy") . '</td><td>'; print $form->select_dolusers(GETPOST("doneby") ? GETPOST("doneby") : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1); print '</td></tr>'; } print '</table>'; print '<br><br>'; print '<table class="border" width="100%">'; // Societe, contact print '<tr><td width="30%" class="nowrap">' . $langs->trans("ActionOnCompany") . '</td><td>'; if (GETPOST('socid', 'int') > 0) { $societe = new Societe($db); $societe->fetch(GETPOST('socid', 'int')); print $societe->getNomUrl(1); print '<input type="hidden" id="socid" name="socid" value="' . GETPOST('socid', 'int') . '">'; } else { $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); //For external user force the company to user company if (!empty($user->societe_id)) { print $form->select_thirdparty_list($user->societe_id, 'socid', '', 1, 1, 0, $events); } else { print $form->select_thirdparty_list('', 'socid', '', 1, 1, 0, $events); } } print '</td></tr>'; print '<tr><td class="nowrap">' . $langs->trans("ActionOnContact") . '</td><td>'; $form->select_contacts(GETPOST('socid', 'int'), GETPOST('contactid'), 'contactid', 1, '', '', 0, 'minwidth200');
/* * View */ $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $form = new Form($db); if ($_GET["socid"]) { $soc = new Societe($db); $soc->id = $_GET["socid"]; $result=$soc->fetch($_GET["socid"]); $head=societe_prepare_head2($soc); dol_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"),0,'company'); /* * Fiche societe en mode visu */ print '<table class="border" width="100%">'; print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>'; print '<td colspan="3">'; print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); print '</td></tr>';
// Used by the include of actions_setnotes.inc.php include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not includ_once /******************************************************************************/ /* Affichage fiche */ /******************************************************************************/ llxHeader('', $langs->trans('CommRequest'), 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'); $form = new Form($db); if ($id > 0 || !empty($ref)) { if ($mesg) { print $mesg; } $now = dol_now(); if ($object->fetch($id, $ref)) { $societe = new Societe($db); if ($societe->fetch($object->socid)) { $head = supplier_proposal_prepare_head($object); dol_fiche_head($head, 'note', $langs->trans('CommRequest'), 0, 'supplier_proposal'); print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php' . (!empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans('BackToList') . '</a>'; // Ref print '<tr><td width="25%">' . $langs->trans('Ref') . '</td><td colspan="3">'; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '</td></tr>'; // Customer if (is_null($object->client)) { $object->fetch_thirdparty(); } print "<tr><td>" . $langs->trans("Supplier") . "</td>"; print '<td colspan="3">' . $object->client->getNomUrl(1) . '</td></tr>'; print '<tr><td>' . $langs->trans('SupplierProposalDate') . '</td><td colspan="3">';
$formfile = new FormFile($db); $formproject = new FormProjets($db); $userstatic = new User($db); $title = $langs->trans("Project") . ' - ' . $object->ref . ' ' . $object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref . ' ' . $object->name; } $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); if ($action == 'create' && $user->rights->projet->creer) { /* * Create */ $thirdparty = new Societe($db); if ($socid > 0) { $thirdparty->fetch($socid); } print_fiche_titre($langs->trans("NewProject"), '', 'title_project'); print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="backtopage" value="' . $backtopage . '">'; dol_fiche_head(); print '<table class="border" width="100%">'; $defaultref = ''; $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
$socid = GETPOST('id', 'int'); // Security check if ($user->societe_id > 0) { $socid = $user->societe_id; } $backtopage = GETPOST('backtopage', 'alpha'); /* * Actions */ if (GETPOST('cancel') && !empty($backtopage)) { header("Location: " . $backtopage); exit; } if (GETPOST("action") == 'setremise') { $soc = new Societe($db); $soc->fetch($_GET["id"]); $result = $soc->set_remise_client($_POST["remise"], $_POST["note"], $user); if ($result > 0) { if (!empty($backtopage)) { header("Location: " . $backtopage); exit; } else { header("Location: remise.php?id=" . $_GET["id"]); exit; } } else { setEventMessage($soc->error, 'errors'); } } /* * View
/** * Function called when a Dolibarrr business event is done. * All functions "run_trigger" are triggered if file is inside directory htdocs/core/triggers * * Following properties must be filled: * $object->actiontypecode (translation action code: AC_OTH, ...) * $object->actionmsg (note, long text) * $object->actionmsg2 (label, short text) * $object->sendtoid (id of contact) * $object->socid * Optionnal: * $object->fk_element * $object->elementtype * * @param string $action Event action code * @param Object $object Object * @param User $user Object user * @param Translate $langs Object langs * @param conf $conf Object conf * @return int <0 if KO, 0 if no triggered ran, >0 if OK */ function run_trigger($action, $object, $user, $langs, $conf) { $key = 'MAIN_AGENDA_ACTIONAUTO_' . $action; //dol_syslog("xxxxxxxxxxx".$key); if (empty($conf->agenda->enabled)) { return 0; } // Module not active, we do nothing if (empty($conf->global->{$key})) { return 0; } // Log events not enabled for this action $ok = 0; // Actions if ($action == 'COMPANY_CREATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("NewCompanyToDolibarr", $object->nom); } $object->actionmsg = $langs->transnoentities("NewCompanyToDolibarr", $object->nom); if ($object->prefix) { $object->actionmsg .= " (" . $object->prefix . ")"; } //$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client); //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->socid = $object->id; $ok = 1; } elseif ($action == 'CONTRACT_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("contracts"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ContractValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("ContractValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ProposalSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ProposalSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'PROPAL_CLOSE_SIGNED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedSignedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'PROPAL_CLOSE_REFUSED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("propal"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("PropalClosedRefusedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("OrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("InvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_CANCEL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'FICHEINTER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("interventions"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $object->fk_element = 0; $object->elementtype = ''; $ok = 1; } elseif ($action == 'FICHEINTER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("interventions"); $langs->load("agenda"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InterventionSentByEMail", $object->ref); } $object->actionmsg = $langs->transnoentities("InterventionSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; // Parameters $object->sendotid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'SHIPPING_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("sendings"); $langs->load("agenda"); $object->actiontypecode = 'AC_SHIP'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("ShippingSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("ShippingSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("orders"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("OrderValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $langs->load("orders"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierOrderSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendotid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $langs->load("orders"); $object->actiontypecode = 'AC_EMAIL'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); } if (empty($object->actionmsg)) { $object->actionmsg = $langs->transnoentities("SupplierInvoiceSentByEMail", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; } // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_PAYED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoicePaidInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'BILL_SUPPLIER_CANCELED') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("bills"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberValidatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberValidatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberSubscriptionAddedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Amount") . ': ' . $object->last_subscription_amount; $object->actionmsg .= "\n" . $langs->transnoentities("Period") . ': ' . dol_print_date($object->last_subscription_date_start, 'day') . ' - ' . dol_print_date($object->last_subscription_date_end, 'day'); $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); } elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberResiliatedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '" . $this->name . "' for action '{$action}' launched by " . __FILE__ . ". id=" . $object->id); $langs->load("other"); $langs->load("members"); $langs->load("agenda"); $object->actiontypecode = 'AC_OTH'; if (empty($object->actionmsg2)) { $object->actionmsg2 = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); } $object->actionmsg = $langs->transnoentities("MemberDeletedInDolibarr", $object->ref); $object->actionmsg .= "\n" . $langs->transnoentities("Member") . ': ' . $object->getFullName($langs); $object->actionmsg .= "\n" . $langs->transnoentities("Type") . ': ' . $object->type; $object->actionmsg .= "\n" . $langs->transnoentities("Author") . ': ' . $user->login; $object->sendtoid = 0; $ok = 1; } // If not found /* else { dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action."); return 0; } */ // Add entry in event table if ($ok) { $now = dol_now(); require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $contactforaction = new Contact($this->db); $societeforaction = new Societe($this->db); if ($object->sendtoid > 0) { $contactforaction->fetch($object->sendtoid); } if ($object->socid > 0) { $societeforaction->fetch($object->socid); } // Insertion action require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); $actioncomm->type_code = $object->actiontypecode; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; $actioncomm->punctual = 1; $actioncomm->percentage = -1; // Not applicable $actioncomm->contact = $contactforaction; $actioncomm->societe = $societeforaction; $actioncomm->author = $user; // User saving action //$actioncomm->usertodo = $user; // User affected to action $actioncomm->userdone = $user; // User doing action $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; $ret = $actioncomm->add($user); // User qui saisit l'action if ($ret > 0) { return 1; } else { $error = "Failed to insert : " . $actioncomm->error . " "; $this->error = $error; dol_syslog("interface_modAgenda_ActionsAuto.class.php: " . $this->error, LOG_ERR); return -1; } } return 0; }
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); $prodcustprice->recuperableonly = preg_match('/\\*/', GETPOST("tva_tx")) ? 1 : 0; $result = $prodcustprice->update($user, 0, $update_child_soc); if ($result < 0) { setEventMessage($prodcustprice->error, 'errors'); } else { setEventMessage($langs->trans('Save'), 'mesgs'); } $action = ''; } /* * View */ $form = new Form($db); $soc = new Societe($db); $result = $soc->fetch($socid); llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer')); if (!empty($conf->notification->enabled)) { $langs->load("mails"); } $head = societe_prepare_head($soc); dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company'); print '<table class="border" width="100%">'; print '<tr><td width="25%">' . $langs->trans("ThirdPartyName") . '</td><td colspan="3">'; print $form->showrefnav($soc, 'socid', '', $user->societe_id ? 0 : 1, 'rowid', 'nom'); print '</td></tr>'; if (!empty($conf->global->SOCIETE_USEPREFIX)) { print '<tr><td>' . $langs->trans('Prefix') . '</td><td colspan="3">' . $soc->prefix_comm . '</td></tr>'; } if ($soc->client) { print '<tr><td>';
/** * Update parameters of third party * @param id id societe * @param user Utilisateur qui demande la mise a jour * @param call_trigger 0=non, 1=oui * @param allowmodcodeclient Inclut modif code client et code compta * @param allowmodcodefournisseur Inclut modif code fournisseur et code compta fournisseur * @return int <0 if KO, >=0 if OK */ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0) { require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); global $langs,$conf; dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); // For triggers if ($call_trigger) { $objectstatic=new Societe($this->db); $objectstatic->fetch($id); $this->oldobject = $objectstatic; } $now=dol_now(); // Clean parameters $this->id=$id; $this->name=$this->name?trim($this->name):trim($this->nom); $this->nom=trim($this->nom); // TODO obsolete $this->address=$this->address?trim($this->address):trim($this->adresse); $this->adresse=$this->address; // TODO obsolete $this->zip=$this->zip?trim($this->zip):trim($this->cp); $this->cp=$this->zip; // TODO obsolete $this->town=$this->town?trim($this->town):trim($this->ville); $this->ville=$this->town; // TODO obsolete $this->departement_id=trim($this->departement_id); $this->pays_id=trim($this->pays_id); $this->tel=trim($this->tel); $this->fax=trim($this->fax); $this->tel = preg_replace("/\s/","",$this->tel); $this->tel = preg_replace("/\./","",$this->tel); $this->fax = preg_replace("/\s/","",$this->fax); $this->fax = preg_replace("/\./","",$this->fax); $this->email=trim($this->email); $this->url=$this->url?clean_url($this->url,0):''; $this->siren=trim($this->siren); $this->siret=trim($this->siret); $this->ape=trim($this->ape); $this->idprof4=trim($this->idprof4); $this->prefix_comm=trim($this->prefix_comm); $this->tva_assuj=trim($this->tva_assuj); $this->tva_intra=dol_sanitizeFileName($this->tva_intra,''); if (empty($this->status)) $this->status = 0; // Local taxes $this->localtax1_assuj=trim($this->localtax1_assuj); $this->localtax2_assuj=trim($this->localtax2_assuj); $this->capital=price2num(trim($this->capital),'MT'); if (empty($this->capital)) $this->capital = 0; $this->effectif_id=trim($this->effectif_id); $this->forme_juridique_code=trim($this->forme_juridique_code); //Gencod $this->gencod=trim($this->gencod); // For automatic creation if ($this->code_client == -1) $this->get_codeclient($this->prefix_comm,0); if ($this->code_fournisseur == -1) $this->get_codefournisseur($this->prefix_comm,1); $this->code_compta=trim($this->code_compta); $this->code_compta_fournisseur=trim($this->code_compta_fournisseur); // Check parameters if (! empty($conf->global->SOCIETE_MAIL_REQUIRED) && ! isValidEMail($this->email)) { $langs->load("errors"); $this->error = $langs->trans("ErrorBadEMail",$this->email); return -1; } $this->db->begin(); // Check name is required and codes are ok or unique. // If error, this->errors[] is filled $result = $this->verify(); if ($result >= 0) { dol_syslog("Societe::Update verify ok"); $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire $sql.= ",datea = '".$this->db->idate($now)."'"; $sql.= ",address = '" . $this->db->escape($this->address) ."'"; $sql.= ",cp = ".($this->zip?"'".$this->zip."'":"null"); $sql.= ",ville = ".($this->town?"'".$this->db->escape($this->town)."'":"null"); $sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'"; $sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'"; $sql .= ",tel = ".($this->tel?"'".$this->db->escape($this->tel)."'":"null"); $sql .= ",fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null"); $sql .= ",email = ".($this->email?"'".$this->db->escape($this->email)."'":"null"); $sql .= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",siren = '". $this->db->escape($this->siren) ."'"; $sql .= ",siret = '". $this->db->escape($this->siret) ."'"; $sql .= ",ape = '". $this->db->escape($this->ape) ."'"; $sql .= ",idprof4 = '". $this->db->escape($this->idprof4) ."'"; $sql .= ",tva_assuj = ".($this->tva_assuj!=''?"'".$this->tva_assuj."'":"null"); $sql .= ",tva_intra = '" . $this->db->escape($this->tva_intra) ."'"; $sql .= ",status = " .$this->status; // Local taxes $sql .= ",localtax1_assuj = ".($this->localtax1_assuj!=''?"'".$this->localtax1_assuj."'":"null"); $sql .= ",localtax2_assuj = ".($this->localtax2_assuj!=''?"'".$this->localtax2_assuj."'":"null"); $sql .= ",capital = ".$this->capital; $sql .= ",prefix_comm = ".($this->prefix_comm?"'".$this->db->escape($this->prefix_comm)."'":"null"); $sql .= ",fk_effectif = ".($this->effectif_id?"'".$this->effectif_id."'":"null"); $sql .= ",fk_typent = ".($this->typent_id?"'".$this->typent_id."'":"0"); $sql .= ",fk_forme_juridique = ".($this->forme_juridique_code?"'".$this->forme_juridique_code."'":"null"); $sql .= ",client = " . ($this->client?$this->client:0); $sql .= ",fournisseur = " . ($this->fournisseur?$this->fournisseur:0); $sql .= ",gencod = ".($this->gencod?"'".$this->gencod."'":"null"); $sql .= ",default_lang = ".($this->default_lang?"'".$this->default_lang."'":"null"); $sql .= ",logo = ".($this->logo?"'".$this->logo."'":"null"); if ($allowmodcodeclient) { //$this->check_codeclient(); $sql .= ", code_client = ".($this->code_client?"'".$this->db->escape($this->code_client)."'":"null"); // Attention get_codecompta peut modifier le code suivant le module utilise if (empty($this->code_compta)) $this->get_codecompta('customer'); $sql .= ", code_compta = ".($this->code_compta?"'".$this->db->escape($this->code_compta)."'":"null"); } if ($allowmodcodefournisseur) { //$this->check_codefournisseur(); $sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->db->escape($this->code_fournisseur)."'":"null"); // Attention get_codecompta peut modifier le code suivant le module utilise if (empty($this->code_compta_fournisseur)) $this->get_codecompta('supplier'); $sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null"); } $sql .= ", fk_user_modif = ".($user->id > 0 ? "'".$user->id."'":"null"); $sql .= " WHERE rowid = '" . $id ."'"; dol_syslog(get_class($this)."::Update sql=".$sql); $resql=$this->db->query($sql); if ($resql) { // Si le fournisseur est classe on l'ajoute $this->AddFournisseurInCategory($this->fournisseur_categorie); $result=$this->insertExtraFields(); if ($result < 0) { $error++; } if (! $error && $call_trigger) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } if (! $error) { dol_syslog(get_class($this)."::Update success"); $this->db->commit(); return 1; } else { $this->db->rollback(); return -1; } } else { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { // Doublon $this->error = $langs->trans("ErrorDuplicateField"); $result = -1; } else { $this->error = $langs->trans("Error sql=".$sql); dol_syslog(get_class($this)."::Update fails update sql=".$sql, LOG_ERR); $result = -2; } $this->db->rollback(); return $result; } } else { $this->db->rollback(); dol_syslog(get_class($this)."::Update fails verify ".join(',',$this->errors), LOG_WARNING); return -3; } }
* Fiche en mode visu */ print '<table class="border" width="100%">'; $linkback = '<a href="' . DOL_URL_ROOT . '/contact/list.php">' . $langs->trans("BackToList") . '</a>'; // Ref print '<tr><td>' . $langs->trans("Ref") . '</td><td colspan="3">'; print $form->showrefnav($contact, 'id', $linkback); print '</td></tr>'; // Name print '<tr><td width="20%">' . $langs->trans("Lastname") . ' / ' . $langs->trans("Label") . '</td><td>' . $contact->lastname . '</td>'; print '<td width="20%">' . $langs->trans("Firstname") . '</td><td width="25%">' . $contact->firstname . '</td></tr>'; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { if ($contact->socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($contact->socid); print '<tr><td width="15%">' . $langs->trans("ThirdParty") . '</td><td colspan="3">' . $objsoc->getNomUrl(1) . '</td></tr>'; } else { print '<tr><td width="15%">' . $langs->trans("ThirdParty") . '</td><td colspan="3">'; print $langs->trans("ContactNotLinkedToCompany"); print '</td></tr>'; } } // Civility print '<tr><td>' . $langs->trans("UserTitle") . '</td><td colspan="3">'; print $contact->getCivilityLabel(); print '</td></tr>'; print '</table>'; print '</div>'; print '<br>'; print $langs->trans("ExportCardToFormat") . ': ';
} } $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 1) { $obj = $db->fetch_object($resql); $socid = $obj->rowid; } $db->free($resql); } } if ($socid > 0) { // Load data of third party $objsoc = new Societe($db); $objsoc->id = $socid; $objsoc->fetch($socid, $to); if ($objsoc->id <= 0) { dol_print_error($db, $objsoc->error); } if ($errmesg) { print "<b>" . $errmesg . "</b><br>"; } /* * Affichage onglets */ $head = societe_prepare_head($objsoc); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); print '<table width="100%" class="notopnoleftnoright">'; print '<tr><td valign="top" class="notopnoleft">'; print '<table class="border" width="100%">'; print '<tr><td width="30%">' . $langs->trans("ThirdPartyName") . '</td><td width="70%" colspan="3">';
/** * \brief Show header of page * \param pdf Object PDF * \param object Object invoice * \param showadress 0=no, 1=yes * \param outputlangs Object lang for output */ function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) { global $langs,$conf,$mysoc; $outputlangs->load("main"); $outputlangs->load("bills"); $outputlangs->load("orders"); $outputlangs->load("companies"); $default_font_size = pdf_getPDFFontSize($outputlangs); // Do not add the BACKGROUND as this is for suppliers //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); $pdf->SetTextColor(0,0,60); $pdf->SetFont('','B', $default_font_size + 3); $posy=$this->marge_haute; $pdf->SetXY($this->marge_gauche,$posy); // Logo /* $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; if ($mysoc->logo) { if (is_readable($logo)) { $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24); } else { $pdf->SetTextColor(200,0,0); $pdf->SetFont('','B', $default_font_size - 2); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); } } else {*/ $text=$this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); //} $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '' , 'R'); $pdf->SetFont('','', $default_font_size + 2); $posy+=6; $pdf->SetXY(100,$posy); if ($object->date) { $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); } else { $pdf->SetTextColor(255,0,0); $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); } if ($showadress) { // Receive email $posy=42; $hautcadre=40; $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY($this->marge_gauche,$posy-5); $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillTo").":",0,"L"); $pdf->SetXY($this->marge_gauche,$posy); $pdf->SetFillColor(230,230,230); $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); // Nom emetteur $carac_emetteur_name=$outputlangs->convToOutputCharset($mysoc->name); $pdf->SetTextColor(0,0,60); $pdf->SetFont('','B', $default_font_size); $pdf->SetXY($this->marge_gauche+2,$posy+3); $pdf->MultiCell(80, 4, $carac_emetteur_name, 0, 'L'); // Sender properties $carac_emetteur = pdf_build_address($outputlangs,$mysoc); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY($this->marge_gauche+2,$posy+8); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); // Client destinataire $posy=42; $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); $pdf->SetXY(100,$posy-5); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("Supplier").":"); // $client = new Societe($this->db); $client->fetch($object->socid); $object->client = $client; // // Cadre client destinataire $pdf->rect(100, $posy, 100, $hautcadre); // Recipient name if (! empty($usecontact)) { // On peut utiliser le nom de la societe du contact if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname; else $socname = $object->client->nom; $carac_client_name=$outputlangs->convToOutputCharset($socname); } else { $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); } $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target'); // Show customer/recipient $pdf->SetXY(102,$posy+3); $pdf->SetFont('','B', $default_font_size); $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY(102,$posy+8); $pdf->MultiCell(96,4, $carac_client, 0, 'L'); } }
static function getHeadForObject($tab_object, $fk_object) { global $db, $conf, $langs, $user; $head = array(); if (empty($tab_object)) { return $head; } if ($tab_object === 'product') { dol_include_once('/product/class/product.class.php'); dol_include_once('/core/lib/product.lib.php'); $object = new Product($db); $object->fetch($fk_object); $head = product_prepare_head($object); } else { if ($tab_object === 'thirdparty') { dol_include_once('/societe/class/societe.class.php'); dol_include_once('/core/lib/company.lib.php'); $object = new Societe($db); $object->fetch($fk_object); $head = societe_prepare_head($object); } else { if ($tab_object === 'contact') { dol_include_once('/contact/class/contact.class.php'); dol_include_once('/core/lib/contact.lib.php'); $object = new Contact($db); $object->fetch($fk_object); $head = contact_prepare_head($object); } else { if ($tab_object === 'user') { dol_include_once('/user/class/user.class.php'); dol_include_once('/core/lib/usergroups.lib.php'); $object = new User($db); $object->fetch($fk_object); $head = user_prepare_head($object); } else { if ($tab_object === 'group') { dol_include_once('/user/class/usergroup.class.php'); dol_include_once('/lib/usergroups.lib.php'); $object = new UserGroup($db); $object->fetch($fk_object); $head = group_prepare_head($object); } else { if ($tab_object === 'project') { dol_include_once('/projet/class/project.class.php'); dol_include_once('/core/lib/project.lib.php'); $object = new Project($db); $object->fetch($fk_object); $head = project_prepare_head($object); } } } } } } return $head; }
if ($withproject) { print '<input type="hidden" name="withproject" value="' . $withproject . '">'; } ?> <div class="tagtd nowrap"><?php echo img_object('', 'contact') . ' ' . $langs->trans("ThirdPartyContacts"); ?> </div> <div class="tagtd nowrap maxwidthonsmartphone"> <?php $selectedCompany = isset($_GET["newcompany"]) ? $_GET["newcompany"] : $object->socid; ?> <?php // add company icon for direct link if ($selectedCompany) { $companystatic->fetch($selectedCompany); echo $companystatic->getNomUrl(2); } ?> <?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?> </div> <div class="tagtd maxwidthonsmartphone"> <?php $nbofcontacts = $form->select_contacts($selectedCompany, '', 'contactid'); ?> </div> <div class="tagtd maxwidthonsmartphone"> <?php $tmpobject = $object;
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } /* * View */ $contactstatic = new Contact($db); $form = new Form($db); if ($socid) { require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $langs->load("companies"); $object = new Societe($db); $result = $object->fetch($socid); $title = $langs->trans("Agenda"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->name . " - " . $title; } llxHeader('', $title); if (!empty($conf->notification->enabled)) { $langs->load("mails"); } $head = societe_prepare_head($object); dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object, 'socid', '', $user->societe_id ? 0 : 1, 'rowid', 'nom'); print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>'; print '<table class="border centpercent">'; // Alias names (commercial, trademark or alias names)