* Copyright (C) 2003 Brian Fraval * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2011-2013 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (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 . */ /** * \file htdocs/societe/card.php * \ingroup societe * \brief Third party card page */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $langs->load("companies"); $langs->load("commercial"); $langs->load("bills"); $langs->load("banks"); $langs->load("users"); if (! empty($conf->categorie->enabled)) $langs->load("categories"); if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); if (! empty($conf->notification->enabled)) $langs->load("mails"); $mesg=''; $error=0; $errors=array(); $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); $cancel = GETPOST('cancel'); $backtopage = GETPOST('backtopage','alpha'); $confirm = GETPOST('confirm'); $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; if (empty($socid) && $action == 'view') $action='create'; $object = new Societe($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycard','globalcard')); if ($action == 'view' && $object->fetch($socid)<=0) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); exit; } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($socid); $canvas = $object->canvas?$object->canvas:GETPOST("canvas"); $objcanvas=null; if (! empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('thirdparty', 'card', $canvas); } // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); /* * Actions */ $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); $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'); if (empty($reshook)) { if ($cancel) { $action=''; if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } } if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) { $object->fetch($socid); $errors = 0; $soc_origin_id = GETPOST('soc_origin', 'int'); $soc_origin = new Societe($db); if ($soc_origin_id <= 0) { $langs->load('errors'); $langs->load('companies'); setEventMessages($langs->trans('ErrorThirdPartyIdIsMandatory', $langs->trans('MergeOriginThirdparty')), null, 'errors'); } else { if (!$errors && $soc_origin->fetch($soc_origin_id) < 1) { setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); $errors++; } if (!$errors) { // TODO Move the merge function into class of object. $db->begin(); // Recopy some data $object->client = $object->client | $soc_origin->client; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; $listofproperties=array( 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', 'model_pdf', 'fk_projet' ); foreach ($listofproperties as $property) { if (empty($object->$property)) $object->$property = $soc_origin->$property; } // Concat some data $listofproperties=array( 'note_public', 'note_private' ); foreach ($listofproperties as $property) { $object->$property = dol_concatdesc($object->$property, $soc_origin->$property); } // Merge extrafields if (is_array($soc_origin->array_options)) { foreach ($soc_origin->array_options as $key => $val) { if (empty($object->array_options[$key])) $object->array_options[$key] = $val; } } // TODO Merge categories $object->update($object->id, $user); // Move links $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', 'Societe' => '/societe/class/societe.class.php', 'Bookmark' => '/bookmarks/class/bookmark.class.php', 'Categorie' => '/categories/class/categorie.class.php', 'ActionComm' => '/comm/action/class/actioncomm.class.php', 'Propal' => '/comm/propal/class/propal.class.php', 'Commande' => '/commande/class/commande.class.php', 'Facture' => '/compta/facture/class/facture.class.php', 'FactureRec' => '/compta/facture/class/facture-rec.class.php', 'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php', 'Contact' => '/contact/class/contact.class.php', 'Contrat' => '/contrat/class/contrat.class.php', 'Expedition' => '/expedition/class/expedition.class.php', 'Fichinter' => '/fichinter/class/fichinter.class.php', 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', 'Livraison' => '/livraison/class/livraison.class.php', 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'User' => '/user/class/user.class.php', ); //First, all core objects must update their tables foreach ($objects as $object_name => $object_file) { require_once DOL_DOCUMENT_ROOT.$object_file; if (!$errors && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) { $errors++; setEventMessages($db->lasterror(), null, 'errors'); } } //External modules should update their ones too if (!$errors) { $reshook = $hookmanager->executeHooks('replaceThirdparty', array( 'soc_origin' => $soc_origin->id, 'soc_dest' => $object->id ), $soc_dest, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $errors++; } } if (!$errors) { //We finally remove the old thirdparty if ($soc_origin->delete($soc_origin->id, $user) < 1) { $errors++; } } if (!$errors) { setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs'); $db->commit(); } else { $langs->load("errors"); setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors'); $db->rollback(); } } } } if (GETPOST('getcustomercode')) { // We defined value code_client $_POST["code_client"]="Acompleter"; } if (GETPOST('getsuppliercode')) { // We defined value code_fournisseur $_POST["code_fournisseur"]="Acompleter"; } if($action=='set_localtax1') { //obtidre selected del combobox $value=GETPOST('lt1'); $object->fetch($socid); $res=$object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if($action=='set_localtax2') { //obtidre selected del combobox $value=GETPOST('lt2'); $object->fetch($socid); $res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } if ($action == 'update_extras') { $object->fetch($socid); // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; if (! $error) { $result = $object->insertExtraFields(); if ($result < 0) $error++; } if ($error) $action = 'edit_extras'; } // Add new or update third party if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (! GETPOST('name')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors'); $error++; $action='create'; } if (GETPOST('client') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors'); $error++; $action='create'; } if (GETPOST('fournisseur') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors'); $error++; $action='create'; } if ($action == 'update') { $ret=$object->fetch($socid); $object->oldcopy = clone $object; } else $object->canvas=$canvas; if (GETPOST("private") == 1) { $object->particulier = GETPOST("private"); $object->name = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha')); $object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int // Add non official properties $object->name_bis = GETPOST('name','alpha'); $object->firstname = GETPOST('firstname','alpha'); } else { $object->name = GETPOST('name', 'alpha'); } $object->name_alias = GETPOST('name_alias'); $object->address = GETPOST('address'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); $object->country_id = GETPOST('country_id', 'int'); $object->state_id = GETPOST('state_id', 'int'); $object->skype = GETPOST('skype', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax','alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL); $object->idprof1 = GETPOST('idprof1', 'alpha'); $object->idprof2 = GETPOST('idprof2', 'alpha'); $object->idprof3 = GETPOST('idprof3', 'alpha'); $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); $object->code_client = GETPOST('code_client', 'alpha'); $object->code_fournisseur = GETPOST('code_fournisseur', 'alpha'); $object->capital = GETPOST('capital', 'alpha'); $object->barcode = GETPOST('barcode', 'alpha'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'alpha'); $object->status = GETPOST('status', 'alpha'); // Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'alpha'); $object->localtax2_assuj = GETPOST('localtax2assuj_value', 'alpha'); $object->localtax1_value = GETPOST('lt1', 'alpha'); $object->localtax2_value = GETPOST('lt2', 'alpha'); $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); $object->typent_id = GETPOST('typent_id'); $object->client = GETPOST('client', 'int'); $object->fournisseur = GETPOST('fournisseur', 'int'); $object->commercial_id = GETPOST('commercial_id', 'int'); $object->default_lang = GETPOST('default_lang'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); // Incoterms if (!empty($conf->incoterm->enabled)) { $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); } // Multicurrency if (!empty($conf->multicurrency->enabled)) { $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) { $error++; $action = ($action=='add'?'create':'edit'); } if (GETPOST('deletephoto')) $object->logo = ''; else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); // Check parameters if (! GETPOST("cancel")) { if (! empty($object->email) && ! isValidEMail($object->email)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadEMail",$object->email); $action = ($action=='add'?'create':'edit'); } if (! empty($object->url) && ! isValidUrl($object->url)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadUrl",$object->url); $action = ($action=='add'?'create':'edit'); } if ($object->fournisseur && ! $conf->fournisseur->enabled) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled"); $action = ($action=='add'?'create':'edit'); } if (! empty($object->webservices_url)) { //Check if has transport, without any the soap client will give error if (strpos($object->webservices_url, "http") === false) { $object->webservices_url = "http://".$object->webservices_url; } if (! isValidUrl($object->webservices_url)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url); $action = ($action=='add'?'create':'edit'); } } // We set country_id, country_code and country for the selected country $object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id; if ($object->country_id) { $tmparray=getCountry($object->country_id,'all'); $object->country_code=$tmparray['code']; $object->country=$tmparray['label']; } // Check for duplicate or mandatory prof id // Only for companies if (!($object->particulier || $private)) { for ($i = 1; $i <= 6; $i++) { $slabel="idprof".$i; $_POST[$slabel]=trim($_POST[$slabel]); $vallabel=$_POST[$slabel]; if ($vallabel && $object->id_prof_verifiable($i)) { if($object->id_prof_exists($i,$vallabel,$object->id)) { $langs->load("errors"); $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); $action = (($action=='add'||$action=='create')?'create':'edit'); } } // Check for mandatory prof id (but only if country is than than ours) if ($mysoc->country_id > 0 && $object->country_id == $mysoc->country_id) { $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); $action = (($action=='add'||$action=='create')?'create':'edit'); } } } } } if (! $error) { if ($action == 'add') { $db->begin(); if (empty($object->client)) $object->code_client=''; if (empty($object->fournisseur)) $object->code_fournisseur=''; $result = $object->create($user); if ($result >= 0) { if ($object->particulier) { dol_syslog("This thirdparty is a personal people",LOG_DEBUG); $result=$object->create_individual($user); if (! $result >= 0) { $error=$object->error; $errors=$object->errors; } } // Customer categories association $custcats = GETPOST( 'custcats', 'array' ); $object->setCategories($custcats, 'customer'); // Supplier categories association $suppcats = GETPOST('suppcats', 'array'); $object->setCategories($suppcats, 'supplier'); // Logo/Photo save $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if ($file_OK) { if (image_format_supported($_FILES['photo']['name'])) { dol_mkdir($dir); if (@is_dir($dir)) { $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); if (! $result > 0) { $errors[] = "ErrorFailedToSaveFile"; } else { // Create thumbs $object->addThumbs($newfile); } } } } else { switch($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; break; case 3: //uploaded file was only partially uploaded $errors[] = "ErrorFilePartiallyUploaded"; break; } } // Gestion du logo de la société } else { if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case { $duplicate_code_error = true; $object->code_fournisseur = null; $object->code_client = null; } $error=$object->error; $errors=$object->errors; } if ($result >= 0) { $db->commit(); if (! empty($backtopage)) { if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id; header("Location: ".$backtopage); exit; } else { $url=$_SERVER["PHP_SELF"]."?socid=".$object->id; if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url=DOL_URL_ROOT."/comm/card.php?socid=".$object->id; else if ($object->fournisseur == 1) $url=DOL_URL_ROOT."/fourn/card.php?socid=".$object->id; header("Location: ".$url); exit; } } else { $db->rollback(); $action='create'; } } if ($action == 'update') { if (GETPOST("cancel")) { if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } else { header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); exit; } } // To not set code if third party is not concerned. But if it had values, we keep them. if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client=''; if (empty($object->fournisseur)&& empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur=''; //var_dump($object);exit; $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0); if ($result <= 0) { $error = $object->error; $errors = $object->errors; } // Customer categories association $categories = GETPOST( 'custcats', 'array' ); $object->setCategories($categories, 'customer'); // Supplier categories association $categories = GETPOST('suppcats', 'array'); $object->setCategories($categories, 'supplier'); // Logo/Photo save $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); if (GETPOST('deletephoto') && $object->photo) { $fileimg=$dir.'/'.$object->logo; $dirthumbs=$dir.'/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if ($file_OK) { if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); if (@is_dir($dir)) { $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); if (! $result > 0) { $errors[] = "ErrorFailedToSaveFile"; } else { // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); // Create mini thumbs for company (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); } } } else { $errors[] = "ErrorBadImageFormat"; } } else { switch($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; break; case 3: //uploaded file was only partially uploaded $errors[] = "ErrorFilePartiallyUploaded"; break; } } // Gestion du logo de la société // Update linked member if (! $error && $object->fk_soc > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; $sql.= " SET fk_soc = NULL WHERE fk_soc = " . $id; if (! $object->db->query($sql)) { $error++; $object->error .= $object->db->lasterror(); } } if (! $error && ! count($errors)) { if (! empty($backtopage)) { header("Location: ".$backtopage); exit; } else { header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid); exit; } } else { $object->id = $socid; $action= "edit"; } } } } // Delete third party if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) { $object->fetch($socid); $result = $object->delete($socid, $user); if ($result > 0) { header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name)); exit; } else { $langs->load("errors"); $error=$langs->trans($object->error); $errors = $object->errors; $action=''; } } // Set parent company if ($action == 'set_thirdparty' && $user->rights->societe->creer) { $object->fetch($socid); $result = $object->set_parent(GETPOST('editparentcompany','int')); } // Set incoterm if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $object->fetch($socid); $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } // Actions to send emails $id=$socid; $trigger_name='COMPANY_SENTBYMAIL'; $paramname='socid'; $mode='emailfromthirdparty'; $trackid='thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $id = $socid; $upload_dir = $conf->societe->dir_output; $permissioncreate=$user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } /* * View */ $form = new Form($db); $formfile = new FormFile($db); $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); if ($socid > 0 && empty($object->id)) { $result=$object->fetch($socid); if ($result <= 0) dol_print_error('',$object->error); } $title=$langs->trans("ThirdParty"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$title,$help_url); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates $objcanvas->display_canvas($action); // Show template } else { // ----------------------------------------- // When used in standard mode // ----------------------------------------- if ($action == 'create') { /* * Creation */ $private=GETPOST("private","int"); if (! empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1; if (empty($private)) $private=0; // Load object modCodeTiers $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module)-4); } $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeClient = new $module; // Load object modCodeFournisseur $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module)-4); } $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeFournisseur = new $module; // Define if customer/prospect or supplier status is set or not if (GETPOST("type")!='f') { $object->client=-1; if (! empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client=3; } } if (GETPOST("type")=='c') { $object->client=3; } // Prospect / Customer if (GETPOST("type")=='p') { $object->client=2; } if (! empty($conf->fournisseur->enabled) && (GETPOST("type")=='f' || (GETPOST("type")=='' && ! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur=1; } $object->name = GETPOST('name', 'alpha'); $object->firstname = GETPOST('firstname', 'alpha'); $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm'); $object->client = GETPOST('client')?GETPOST('client'):$object->client; if(empty($duplicate_code_error)) { $object->code_client = GETPOST('code_client', 'alpha'); $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; } else { setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'),'', 'warnings'); } $object->code_fournisseur = GETPOST('code_fournisseur', 'alpha'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); $object->state_id = GETPOST('state_id', 'int'); $object->skype = GETPOST('skype', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL); $object->capital = GETPOST('capital', 'alpha'); $object->barcode = GETPOST('barcode', 'alpha'); $object->idprof1 = GETPOST('idprof1', 'alpha'); $object->idprof2 = GETPOST('idprof2', 'alpha'); $object->idprof3 = GETPOST('idprof3', 'alpha'); $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); $object->typent_id = GETPOST('typent_id', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); $object->civility_id = GETPOST('civility_id', 'int'); $object->tva_assuj = GETPOST('assujtva_value', 'int'); $object->status = GETPOST('status', 'int'); //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'int'); $object->localtax2_assuj = GETPOST('localtax2assuj_value', 'int'); $object->localtax1_value =GETPOST('lt1', 'int'); $object->localtax2_value =GETPOST('lt2', 'int'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); $object->commercial_id = GETPOST('commercial_id', 'int'); $object->default_lang = GETPOST('default_lang'); $object->logo = (isset($_FILES['photo'])?dol_sanitizeFileName($_FILES['photo']['name']):''); // Gestion du logo de la société $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos"; $file_OK = (isset($_FILES['photo'])?is_uploaded_file($_FILES['photo']['tmp_name']):false); if ($file_OK) { if (image_format_supported($_FILES['photo']['name'])) { dol_mkdir($dir); if (@is_dir($dir)) { $newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1); if (! $result > 0) { $errors[] = "ErrorFailedToSaveFile"; } else { // Create thumbs $object->addThumbs($newfile); } } } } // We set country_id, country_code and country for the selected country $object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id; if ($object->country_id) { $tmparray=getCountry($object->country_id,'all'); $object->country_code=$tmparray['code']; $object->country=$tmparray['label']; } $object->forme_juridique_code=GETPOST('forme_juridique_code'); /* Show create form */ $linkback=""; print load_fiche_titre($langs->trans("NewThirdParty"),$linkback,'title_companies.png'); if (! empty($conf->use_javascript_ajax)) { print "\n".''."\n"; print '
'; print '
'; print $langs->trans("ThirdPartyType").':     '; print '
'; print ''; print '     '; print ''; print '
'; print "
\n"; } dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; dol_fiche_head(null, 'card', '', 0, ''); print ''; // Name, firstname print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } print ''; // If javascript on, we show option individual if ($conf->use_javascript_ajax) { print ''; print ''; print ''; // Title print ''; print ''; } // Alias names (commercial, trademark or alias names) print ''; print ''; // Prospect/Customer print ''; print ''; print ''; if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) { // Supplier print ''; print ''; print ''; } // Status print ''; // Barcode if (! empty($conf->barcode->enabled)) { print ''; print ''; } // Address print ''; print ''; // Zip / Town print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } // Email web print ''; print ''; print ''; print ''; // Skype if (! empty($conf->skype->enabled)) { print ''; print ''; } // Phone / Fax print ''; print ''; print ''; print ''; // Prof ids $i=1; $j=0; while ($i <= 6) { $idprof=$langs->transcountry('ProfId'.$i,$object->country_code); if ($idprof!='-') { $key='idprof'.$i; if (($j % 2) == 0) print ''; $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; print ''; if (($j % 2) == 1) print ''; $j++; } $i++; } if ($j % 2 == 1) print ''; // Vat is used print ''; print ''; print ''; print ''; print ''; // Local Taxes //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { print ''; } elseif($mysoc->localtax1_assuj=="1") { print ''; } elseif($mysoc->localtax2_assuj=="1") { print ''; } // Type - Size print ''; print ''; // Legal Form print ''; print ''; // Capital print ''; print ''; if (! empty($conf->global->MAIN_MULTILANGS)) { print ''; print ''; } if ($user->rights->societe->client->voir) { // Assign a Name print ''; print ''; print ''; } // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; print ''; print ''; } // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { $langs->load('categories'); // Customer if ($object->prospect || $object->client) { print '"; } // Supplier if ($object->fournisseur) { print '"; } } // Multicurrency if (! empty($conf->multicurrency->enabled)) { print ''; print ''; print ''; } // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } // Ajout du logo print ''; print ''; print ''; print ''; print '
'; if ($object->particulier || $private) { print ''.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName','name').''; } else { print ''.fieldLabel('ThirdPartyName','name').''; } print ''.$langs->trans('Prefix').'
'.fieldLabel('FirstName','firstname').'
'.fieldLabel('UserTitle','civility_id').''; print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'
'.fieldLabel('ProspectCustomer','customerprospect',1).''; $selected=isset($_POST['client'])?GETPOST('client'):$object->client; print ''.fieldLabel('CustomerCode','customer_code').''; print '
'; $tmpcode=$object->code_client; if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); print ''; print ''; $s=$modCodeClient->getToolTip($langs,$object,0); print $form->textwithpicto('',$s,1); print '
'; print '
'.fieldLabel('Supplier','fournisseur',1).''; $default = -1; if (! empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default=1; print $form->selectyesno("fournisseur", (isset($_POST['fournisseur'])?GETPOST('fournisseur'):(GETPOST("type") == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0)); print ''.fieldLabel('SupplierCode','supplier_code').''; print '
'; $tmpcode=$object->code_fournisseur; if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); print ''; print ''; $s=$modCodeFournisseur->getToolTip($langs,$object,1); print $form->textwithpicto('',$s,1); print '
'; print '
'.fieldLabel('Status','status').''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),1); print '
'.fieldLabel('Gencod','barcode').''; print '
'.fieldLabel('Address','address').'
'.fieldLabel('Zip','zipcode').''; print $formcompany->select_ziptown($object->zip,'zipcode',array('town','selectcountry_id','state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent'); print ''.fieldLabel('Town','town').''; print $formcompany->select_ziptown($object->town,'town',array('zipcode','selectcountry_id','state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent'); print '
'.fieldLabel('Country','selectcountry_id').''; print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.fieldLabel('State','state_id').''; if ($object->country_id) print $formcompany->select_state($object->state_id,$object->country_code); else print $countrynotdefined; print '
'.fieldLabel('EMail','email').(! empty($conf->global->SOCIETE_MAIL_REQUIRED)?'*':'').'
'.fieldLabel('Web','url').'
'.fieldLabel('Skype','skype').'
'.fieldLabel('Phone','phone').''.fieldLabel('Fax','fax').'
'.fieldLabel($idprof,$key, (empty($conf->global->$idprof_mandatory)?0:1)).''; print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); print '
'.fieldLabel('VATIsUsed','assujtva_value').''; print $form->selectyesno('assujtva_value',(isset($conf->global->THIRDPARTY_DEFAULT_USEVAT)?$conf->global->THIRDPARTY_DEFAULT_USEVAT:1),1); // Assujeti par defaut en creation print ''.fieldLabel('VATIntra','intra_vat').''; $s = ''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.=' '; if (! empty($conf->use_javascript_ajax)) { print "\n"; print ''; print "\n"; $s.=''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { $s.='country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } print $s; print '
'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1); print ''.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); print '
'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax1assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1:0),1); print '
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); print '
'.fieldLabel('ThirdPartyType','typent_id').''."\n"; $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam); if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''.fieldLabel('Staff','effectif_id').''; print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id); if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.fieldLabel('JuridicalStatus','forme_juridique_code').''; if ($object->country_id) { print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); } else { print $countrynotdefined; } print '
'.fieldLabel('Capital','capital').' '; print ''.$langs->trans("Currency".$conf->currency).'
'.fieldLabel('DefaultLang','default_lang').''."\n"; print $formadmin->select_language(($object->default_lang?$object->default_lang:$conf->global->MAIN_LANG_DEFAULT),'default_lang',0,0,1,0,0,'maxwidth200onsmartphone'); print '
'.fieldLabel('AllocateCommercial','commercial_id').''; print $form->select_dolusers((! empty($object->commercial_id)?$object->commercial_id:$user->id),'commercial_id',1); // Add current user by default print '
'.fieldLabel('IncotermLabel','incoterm_id').''; print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); print '
' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); print "
' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, null, "90%"); print "
'.fieldLabel('Currency','multicurrency_code').''; print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); print '
'.fieldLabel('Logo','photoinput').''; print ''; print '
'."\n"; dol_fiche_end(); print '
'; print ''; if (! empty($backtopage)) { print '     '; print ''; } else { print '     '; print ''; } print '
'."\n"; print '
'."\n"; } elseif ($action == 'edit') { /* * Edition */ //print load_fiche_titre($langs->trans("EditCompany")); if ($socid) { $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); // Load object modCodeTiers $module=(! empty($conf->global->SOCIETE_CODECLIENT_ADDON)?$conf->global->SOCIETE_CODECLIENT_ADDON:'mod_codeclient_leopard'); if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module)-4); } $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeClient = new $module($db); // We verified if the tag prefix is used if ($modCodeClient->code_auto) { $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed(); } $module=$conf->global->SOCIETE_CODECLIENT_ADDON; if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module)-4); } $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); foreach ($dirsociete as $dirroot) { $res=dol_include_once($dirroot.$module.'.php'); if ($res) break; } $modCodeFournisseur = new $module($db); // On verifie si la balise prefix est utilisee if ($modCodeFournisseur->code_auto) { $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); } $object->oldcopy = clone $object; if (GETPOST('name')) { // We overwrite with values if posted $object->name = GETPOST('name', 'alpha'); $object->prefix_comm = GETPOST('prefix_comm', 'alpha'); $object->client = GETPOST('client', 'int'); $object->code_client = GETPOST('code_client', 'alpha'); $object->fournisseur = GETPOST('fournisseur', 'int'); $object->code_fournisseur = GETPOST('code_fournisseur', 'alpha'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); $object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id; $object->state_id = GETPOST('state_id', 'int'); $object->skype = GETPOST('skype', 'alpha'); $object->phone = GETPOST('phone', 'alpha'); $object->fax = GETPOST('fax', 'alpha'); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL); $object->capital = GETPOST('capital', 'alpha'); $object->idprof1 = GETPOST('idprof1', 'alpha'); $object->idprof2 = GETPOST('idprof2', 'alpha'); $object->idprof3 = GETPOST('idprof3', 'alpha'); $object->idprof4 = GETPOST('idprof4', 'alpha'); $object->idprof5 = GETPOST('idprof5', 'alpha'); $object->idprof6 = GETPOST('idprof6', 'alpha'); $object->typent_id = GETPOST('typent_id', 'int'); $object->effectif_id = GETPOST('effectif_id', 'int'); $object->barcode = GETPOST('barcode', 'alpha'); $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); $object->default_lang = GETPOST('default_lang', 'alpha'); $object->tva_assuj = GETPOST('assujtva_value', 'int'); $object->tva_intra = GETPOST('tva_intra', 'alpha'); $object->status = GETPOST('status', 'int'); // Webservices url/key $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL); $object->webservices_key = GETPOST('webservices_key', 'san_alpha'); //Incoterms if (!empty($conf->incoterm->enabled)) { $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha'); } //Local Taxes $object->localtax1_assuj = GETPOST('localtax1assuj_value'); $object->localtax2_assuj = GETPOST('localtax2assuj_value'); $object->localtax1_value =GETPOST('lt1'); $object->localtax2_value =GETPOST('lt2'); // We set country_id, and country_code label of the chosen country if ($object->country_id > 0) { $tmparray=getCountry($object->country_id,'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; } } dol_htmloutput_errors($error,$errors); if($object->localtax1_assuj==0){ $sub=0; }else{$sub=1;} if($object->localtax2_assuj==0){ $sub2=0; }else{$sub2=1;} print "\n".''."\n"; if ($conf->use_javascript_ajax) { print "\n".''."\n"; } print '
'; print ''; print ''; print ''; if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); print '
'; print ''; // Ref/ID if (! empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; } // Name print ''; print ''; // Alias names (commercial, trademark or alias names) print ''; print ''; // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } // Prospect/Customer print ''; print ''; print ''; // Supplier if (! empty($conf->fournisseur->enabled) && ! empty($user->rights->fournisseur->lire)) { print ''; print ''; print ''; } // Barcode if (! empty($conf->barcode->enabled)) { print ''; print ''; } // Status print ''; // Address print ''; print ''; // Zip / Town print ''; // Country print ''; // State if (empty($conf->global->SOCIETE_DISABLE_STATE)) { print ''; } // EMail / Web print ''; print ''; print ''; print ''; // Skype if (! empty($conf->skype->enabled)) { print ''; print ''; } // Phone / Fax print ''; print ''; print ''; print ''; // Prof ids $i=1; $j=0; while ($i <= 6) { $idprof=$langs->transcountry('ProfId'.$i,$object->country_code); if ($idprof!='-') { $key='idprof'.$i; if (($j % 2) == 0) print ''; $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; if(empty($conf->global->$idprof_mandatory)) print ''; if (($j % 2) == 1) print ''; $j++; } $i++; } if ($j % 2 == 1) print ''; // VAT is used print ''; // Local Taxes //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { print ''; print ''; } elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") { print ''; } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") { print ''; } // VAT Code print ''; print ''; print ''; // Type - Size print ''; print ''; // Juridical type print ''; // Capital print ''; print ''; // Default language if (! empty($conf->global->MAIN_MULTILANGS)) { print ''; print ''; } // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer if ($object->prospect || $object->client) { print ''; print '"; } // Supplier if ($object->fournisseur) { print ''; print '"; } } // Multicurrency if (! empty($conf->multicurrency->enabled)) { print ''; print ''; print ''; } // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } // Webservices url/key if (!empty($conf->syncsupplierwebservices->enabled)) { print ''; print ''; print ''; print ''; } // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; print ''; print ''; } // Logo print ''; print ''; print ''; print ''; print '
'.$langs->trans("ID").''; print $object->ref; print '
'.fieldLabel('ThirdPartyName','name',1).'
'.fieldLabel('Prefix','prefix').''; // It does not change the prefix mode using the auto numbering prefix if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) { print ''; print $object->prefix_comm; } else { print ''; } print '
'.fieldLabel('ProspectCustomer','customerprospect',1).''.fieldLabel('CustomerCode','customer_code').''; print '
'; if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) { $tmpcode=$object->code_client; if (empty($tmpcode) && ! empty($object->oldcopy->code_client)) $tmpcode=$object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. if (empty($tmpcode) && ! empty($modCodeClient->code_auto)) $tmpcode=$modCodeClient->getNextValue($object,0); print ''; } else if ($object->codeclient_modifiable()) { print ''; } else { print $object->code_client; print ''; } print ''; $s=$modCodeClient->getToolTip($langs,$object,0); print $form->textwithpicto('',$s,1); print '
'; print '
'.fieldLabel('Supplier','fournisseur',1).''; print $form->selectyesno("fournisseur",$object->fournisseur,1); print ''.fieldLabel('SupplierCode','supplier_code').''; print '
'; if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) { $tmpcode=$object->code_fournisseur; if (empty($tmpcode) && ! empty($object->oldcopy->code_fournisseur)) $tmpcode=$object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value. if (empty($tmpcode) && ! empty($modCodeFournisseur->code_auto)) $tmpcode=$modCodeFournisseur->getNextValue($object,1); print ''; } else if ($object->codefournisseur_modifiable()) { print ''; } else { print $object->code_fournisseur; print ''; } print ''; $s=$modCodeFournisseur->getToolTip($langs,$object,1); print $form->textwithpicto('',$s,1); print '
'; print '
'.fieldLabel('Gencod','barcode').''; print '
'.fieldLabel('Status','status').''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$object->status); print '
'.fieldLabel('Address','address').'
'.fieldLabel('Zip','zipcode').''; print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth50onsmartphone'); print ''.fieldLabel('Town','town').''; print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'.fieldLabel('Country','selectcounty_id').''; print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.fieldLabel('State','state_id').''; print $formcompany->select_state($object->state_id,$object->country_code); print '
'.fieldLabel('EMail','email',(! empty($conf->global->SOCIETE_MAIL_REQUIRED))).'
'.fieldLabel('Web','url').'
'.fieldLabel('Skype','skype').'
'.fieldLabel('Phone','phone').''.fieldLabel('Fax','fax').'
'.fieldLabel($idprof,$key).''; else print ''.fieldLabel($idprof,$key).''; print $formcompany->get_input_id_prof($i,$key,$object->$key,$object->country_code); print '
'.fieldLabel('VATIsUsed','assujtva_value').''; print $form->selectyesno('assujtva_value',$object->tva_assuj,1); print '
'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').''; print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1); if(! isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type",$mysoc->country_code).': '; $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type",$mysoc->country_code).': '; $formcompany->select_localtax(2,$object->localtax2_value, "lt2"); print ''; } print '
'.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').''; print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1); if(! isOnlyOneLocalTax(1)) { print ' '.$langs->transcountry("Type",$mysoc->country_code).': '; $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } print '
'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if(! isOnlyOneLocalTax(2)) { print ' '.$langs->transcountry("Type",$mysoc->country_code).': '; $formcompany->select_localtax(2,$object->localtax2_value, "lt2"); print ''; } print '
'.fieldLabel('VATIntra','intra_vat').''; $s =''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.='   '; if ($conf->use_javascript_ajax) { print "\n"; print ''; print "\n"; $s.=''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { $s.='country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } print $s; print '
'.fieldLabel('ThirdPartyType','typent_id').''; print $form->selectarray("typent_id",$formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''.fieldLabel('Staff','effectif_id').''; print $form->selectarray("effectif_id",$formcompany->effectif_array(0), $object->effectif_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.fieldLabel('JuridicalStatus','forme_juridique_code').''; print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); print '
'.fieldLabel('Capital','capital').' '.$langs->trans("Currency".$conf->currency).'
'.fieldLabel('DefaultLang','default_lang').''."\n"; print $formadmin->select_language($object->default_lang,'default_lang',0,0,1); print '
' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); print "
' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); foreach ($cats as $cat) { $arrayselected[] = $cat->id; } print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); print "
'.fieldLabel('Currency','multicurrency_code').''; print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); print '
'.fieldLabel('WebServiceURL','webservices_url').''.fieldLabel('WebServiceKey','webservices_key').'
'.fieldLabel('IncotermLabel','incoterm_id').''; print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:'')); print '
'.fieldLabel('Logo','photoinput').''; if ($object->logo) print $form->showphoto('societe',$object); $caneditfield=1; if ($caneditfield) { if ($object->logo) print "
\n"; print ''; if ($object->logo) print ''; //print ''; print ''; print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; } print '
'; print '
'; dol_fiche_end(); print '
'; print ''; print '     '; print ''; print '
'; print '
'; } } else { /* * View */ if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company'); // Confirm delete third party if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); } if ($action == 'merge') { $formquestion = array( array( 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') ) ); print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 200); } dol_htmloutput_errors($error,$errors); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); print '
'; print '
'; print '
'; print ''; // Prospect/Customer print ''; // Supplier if (! empty($conf->fournisseur->enabled)) { print ''; } // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; print $htmllogobar; $htmllogobar=''; print ''; } // Customer code if ($object->client) { print ''; print $htmllogobar; $htmllogobar=''; print ''; } // Supplier code if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { print ''; print $htmllogobar; $htmllogobar=''; print ''; } // Barcode if (! empty($conf->barcode->enabled)) { print ''; if ($htmllogobar) $htmllogobar.=$form->showbarcode($object); print $htmllogobar; $htmllogobar=''; print ''; } // Prof ids $i=1; $j=0; while ($i <= 6) { $idprof=$langs->transcountry('ProfId'.$i,$object->country_code); if ($idprof!='-') { //if (($j % 2) == 0) print ''; print ''; print ''; //if (($j % 2) == 1) print ''; print ''; $j++; } $i++; } //if ($j % 2 == 1) print ''; // VAT is used print ''; print ''; // Local Taxes //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { print ''; if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) { print ''; print ''; print ''; print ''; if($action == 'editRE') { print ''; } else { print ''; } print ''; } if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) { print ''; print ''; print ''; print ''; if($action == 'editIRPF'){ print ''; }else{ print ''; } print ''; } } elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") { print ''; if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) { print ''; print ''; print ''; print ''; if($action == 'editRE'){ print ''; }else{ print ''; } print ''; } } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") { print ''; if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) { print ''; print ''; print ''; print ''; if($action == 'editIRPF'){ print ''; }else{ print ''; } print ''; } } /* if ($mysoc->country_code=='ES' && $mysoc->localtax2_assuj!="1" && ! empty($conf->fournisseur->enabled) && $object->fournisseur==1) { print ''; } */ // VAT Code print ''; print ''; print ''; // Type + Staff $arr = $formcompany->typent_array(1); $object->typent= $arr[$object->typent_code]; print ''; print ''; print '
'.$langs->trans('ProspectCustomer').''; print $object->getLibCustProspStatut(); print '
'.$langs->trans('Supplier').''; print yn($object->fournisseur); print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'; print $langs->trans('Gencod').''.$object->barcode; print '
'.$idprof.''; $key='idprof'.$i; print $object->$key; if ($object->$key) { if ($object->id_prof_check($i,$object) > 0) print '   '.$object->id_prof_url($i,$object); else print ' ('.$langs->trans("ErrorWrongValue").')'; } print '
'; print $langs->trans('VATIsUsed'); print ''; print yn($object->tva_assuj); print '
'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).''; print yn($object->localtax1_assuj); print '
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print yn($object->localtax2_assuj); print '
'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''.$object->localtax1_value.'
'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; $formcompany->select_localtax(2,$object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
'.$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code).''; print yn($object->localtax1_assuj); print '
'.$langs->transcountry("TypeLocaltax1", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''.$object->localtax1_value.'
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print yn($object->localtax2_assuj); print '
'.$langs->transcountry("TypeLocaltax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).''; $formcompany->select_localtax(2,$object->localtax2_value, "lt2"); print ''.$object->localtax2_value.'
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print yn($object->localtax2_assuj); print '
'.$langs->trans('VATIntra').''; if ($object->tva_intra) { $s=''; $s.=$object->tva_intra; $s.=''; if (empty($conf->global->MAIN_DISABLEVATCHECK)) { $s.='   '; if ($conf->use_javascript_ajax) { print "\n"; print ''; print "\n"; $s.=''.$langs->trans("VATIntraCheck").''; $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1); } else { $s.='country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').''; } } print $s; } else { print ' '; } print '
'.$langs->trans("ThirdPartyType").''.$object->typent.'
'.$langs->trans("Staff").''.$object->effectif.'
'; print '
'; print '
'; print '
'; print ''; // Tags / categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer if ($object->prospect || $object->client) { print ''; print '"; } // Supplier if ($object->fournisseur) { print ''; print '"; } } // Legal print ''; // Capital print ''; // Default language if (! empty($conf->global->MAIN_MULTILANGS)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''; } // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; print ''; } // Multicurrency if (! empty($conf->multicurrency->enabled)) { print ''; print ''; print ''; } // Other attributes $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { // Payment term print ''; print ''; } // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; // Module Adherent if (! empty($conf->adherent->enabled)) { $langs->load("members"); print ''; print ''; print "\n"; } // Webservices url/key if (!empty($conf->syncsupplierwebservices->enabled)) { print ''; print ''; } print '
' . $langs->trans("CustomersCategoriesShort") . ''; print $form->showCategories($object->id, 'customer', 1); print "
' . $langs->trans("SuppliersCategoriesShort") . ''; print $form->showCategories($object->id, 'supplier', 1); print "
'.$langs->trans('JuridicalStatus').''.$object->forme_juridique.'
'.$langs->trans('Capital').''; if ($object->capital) print price($object->capital,'',$langs,0,-1,-1, $conf->currency); else print ' '; print '
'.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($object->default_lang); //print ($s?$s.' ':''); $langs->load("languages"); $labellang = ($object->default_lang?$langs->trans('Language_'.$object->default_lang):''); print $labellang; print '
'; print '
'; print $langs->trans('IncotermLabel'); print ''; if ($user->rights->societe->creer) print ''.img_edit('',1).''; else print ' '; print '
'; print '
'; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); } else { print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?socid='.$object->id); } print '
'.fieldLabel('Currency','multicurrency_code').''; print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code,1) : ''; print '
'; print ''; if ($action != 'editparentcompany') print ''; print '
'; print $langs->trans('ParentCompany'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'
'; print '
'; if ($action == 'editparentcompany') { $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'editparentcompany','s.rowid <> '.$object->id,1); } else { $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'none','s.rowid <> '.$object->id,1); } print '
'.$langs->trans("LinkedToDolibarrMember").''; $adh=new Adherent($db); $result=$adh->fetch('','',$object->id); if ($result > 0) { $adh->ref=$adh->getFullName($langs); print $adh->getNomUrl(1); } else { print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; } print '
'.$langs->trans("WebServiceURL").''.dol_print_url($object->webservices_url).''.$langs->trans('WebServiceKey').''.$object->webservices_key.'
'; print '
'; print '
'; print '
'; dol_fiche_end(); /* * Actions */ print '
'."\n"; $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $at_least_one_email_contact = false; $TContact = $object->contact_array_objects(); foreach ($TContact as &$contact) { if (!empty($contact->email)) { $at_least_one_email_contact = true; break; } } if (! empty($object->email) || $at_least_one_email_contact) { $langs->load("mails"); print ''; } else { $langs->load("mails"); print ''; } if ($user->rights->societe->creer) { print ''."\n"; } if ($user->rights->societe->supprimer) { print ''; } if ($user->rights->societe->supprimer) { if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile { print '
'.$langs->trans('Delete').'
'."\n"; } else { print ''."\n"; } } } print '
'."\n"; //Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } if ($action == 'presend') { /* * Affiche formulaire mail */ // By default if $action=='presend' $titreform='SendMail'; $topicmail=''; $action='send'; $modelmail='thirdparty'; print '
'; print '
'; print '
'; print load_fiche_titre($langs->trans($titreform)); dol_fiche_head(); // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->default_lang; // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); if($formmail->fromtype === 'user'){ $formmail->fromid = $user->id; } $formmail->trackid='thi'.$object->id; if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id); } $formmail->withfrom=1; $formmail->withtopic=1; $liste=array(); foreach ($object->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; $formmail->withto=GETPOST('sendto')?GETPOST('sendto'):$liste; $formmail->withtofree=1; $formmail->withtocc=$liste; $formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC; $formmail->withfile=2; $formmail->withbody=1; $formmail->withdeliveryreceipt=1; $formmail->withcancel=1; // Tableau des substitutions //$formmail->setSubstitFromObject($object); $formmail->substit['__THIRDPARTY_NAME__']=$object->name; $formmail->substit['__SIGNATURE__']=$user->signature; $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; //Find the good contact adress /* $custcontact=''; $contactarr=array(); $contactarr=$object->liste_contact(-1,'external'); if (is_array($contactarr) && count($contactarr)>0) { foreach($contactarr as $contact) { if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $contactstatic=new Contact($db); $contactstatic->fetch($contact['id']); $custcontact=$contactstatic->getFullName($langs,1); } } if (!empty($custcontact)) { $formmail->substit['__CONTACTCIVNAME__']=$custcontact; } }*/ // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['socid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?socid='.$object->id; // Init list of files if (GETPOST("mode")=='init') { $formmail->clear_attached_files(); $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } print $formmail->get_form(); dol_fiche_end(); } else { if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { print '
'; print ''; // ancre /* * Documents generes */ $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; $genallowed=$user->rights->societe->lire; $delallowed=$user->rights->societe->creer; $var=true; print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); print '
'; print '
'; print '
'; } print '

'; // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) { $result=show_subsidiaries($conf,$langs,$db,$object); } // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } // Addresses list if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) { $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); } } } } // End of page llxFooter(); $db->close();