--- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_agenda.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_agenda.php @@ -30 +29,0 @@ -// Load Dolibarr environment @@ -35,2 +33,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -38,2 +35 @@ -// Load translation files required by the page -$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal')); +$langs->loadLangs(array("companies", "bills", "propal", "orders")); @@ -41,9 +37,4 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartyagenda'; - -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); +if (GETPOST('actioncode', 'array')) +{ + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; @@ -51,2 +42,4 @@ - -$search_rowid = GETPOST('search_rowid'); +else +{ + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} @@ -55,3 +48,8 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'societe', $socid, '&societe'); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -59,3 +57 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -65,9 +61,2 @@ -if (!$sortfield) { - $sortfield = 'a.datep,a.id'; -} -if (!$sortorder) { - $sortorder = 'DESC,DESC'; -} - -// Initialize technical objects -$object = new Societe($db); +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; @@ -76,15 +65 @@ -$hookmanager->initHooks(array('agendathirdparty', 'globalcard')); - -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} - -$result = $object->fetch($socid); -if ($result <= 0) { - accessforbidden('Third party not found'); -} - -$result = restrictedArea($user, 'societe', $socid, '&societe'); - +$hookmanager->initHooks(array('agendathirdparty')); @@ -99,3 +74 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -103,6 +76,8 @@ -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } @@ -110,5 +85,6 @@ - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; - } + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $actioncode = ''; + $search_agenda_label = ''; + } @@ -125,6 +101,4 @@ -$title = $langs->trans("Agenda"); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name." - ".$title; -} -$help_url = ''; -llxHeader('', $title, $help_url); +if ($socid > 0) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; @@ -132,4 +106,2 @@ -if (isModEnabled('notification')) { - $langs->load("mails"); -} -$head = societe_prepare_head($object); + $object = new Societe($db); + $result = $object->fetch($socid); @@ -136,0 +109,3 @@ + $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); @@ -138 +113,2 @@ -print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, $object->picto); + if (!empty($conf->notification->enabled)) $langs->load("mails"); + $head = societe_prepare_head($object); @@ -140 +116 @@ -$linkback = ''.$langs->trans("BackToList").''; + dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company'); @@ -142 +118 @@ -$morehtmlref = ''; + $linkback = ''.$langs->trans("BackToList").''; @@ -144 +120 @@ -dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); @@ -146 +122 @@ -print '
'; + print '
'; @@ -148 +124 @@ -print '
'; + print '
'; @@ -150,2 +126,2 @@ -$object->info($socid); -dol_print_object_info($object, 1); + $object->info($socid); + dol_print_object_info($object, 1); @@ -153 +129 @@ -print '
'; + print '
'; @@ -155 +131 @@ -print dol_get_fiche_end(); + dol_fiche_end(); @@ -159 +135 @@ -// Actions buttons + // Actions buttons @@ -161,2 +137,2 @@ -$objthirdparty = $object; -$objcon = new stdClass(); + $objthirdparty = $object; + $objcon = new stdClass(); @@ -164,42 +140,10 @@ -$out = ''; -$permok = $user->hasRight('agenda', 'myactions', 'create'); -if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { - $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); - } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); - $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel'); -} - -$morehtmlright = ''; - -$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id; -$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); -$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; -$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); - -// // Show link to send an email (if read and not closed) -// $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; -// $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle'; -// $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus); - -// // Show link to add a private message (if read and not closed) -// $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; -// $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle'; -// $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); - -if (isModEnabled('agenda')) { - if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); - } -} - -if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { - print '
'; - - $param = '&socid='.urlencode($socid); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) + { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; @@ -208,4 +151,0 @@ - // Try to know count of actioncomm from cache - require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; - $cachekey = 'count_events_thirdparty_'.$object->id; - $nbEvent = dol_getcache($cachekey); @@ -213,4 +153,2 @@ - $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); - if (!empty($conf->dol_optimize_smallscreen)) { - $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); - } + //print '
'; + //print '
'; @@ -218 +155,0 @@ - print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); @@ -220,4 +157,8 @@ - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; - $filters['search_rowid'] = $search_rowid; + $newcardbutton = ''; + if (!empty($conf->agenda->enabled)) + { + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } + } @@ -225,2 +166,18 @@ - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); + if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) + { + print '
'; + + $param = '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + + print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, ''); + //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } @@ -228 +184,0 @@ - --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_ajaxcompanies.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_ajaxcompanies.php @@ -0,0 +1,112 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * 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/ajaxcompanies.php + * \brief File to return Ajax response on third parties request + */ + +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); + +require '../main.inc.php'; + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +//print ''."\n"; + +dol_syslog(join(',', $_GET)); + + +// Generation liste des societes +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) +{ + $return_arr = array(); + + // Define filter on text typed + $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; + if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; + + $sql = "SELECT rowid, nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + if ($socid) + { + $sql .= " AND ("; + // Add criteria on name/code + if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index + { + $sql .= "nom LIKE '".$db->escape($socid)."%'"; + $sql .= " OR code_client LIKE '".$db->escape($socid)."%'"; + $sql .= " OR code_fournisseur LIKE '".$db->escape($socid)."%'"; + } + else + { + $sql .= "nom LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR code_client LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR code_fournisseur LIKE '%".$db->escape($socid)."%'"; + } + if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR rowid = '".$db->escape($socid)."'"; + $sql .= ")"; + } + //if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters + $sql .= " ORDER BY nom ASC"; + + //dol_syslog("ajaxcompanies", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + while ($row = $db->fetch_array($resql)) + { + $label = $row['nom']; + if ($socid) $label = preg_replace('/('.preg_quote($socid, '/').')/i', '$1', $label, 1); + $row_array['label'] = $label; + $row_array['value'] = $row['nom']; + $row_array['key'] = $row['rowid']; + + array_push($return_arr, $row_array); + } + + echo json_encode($return_arr); + } + else + { + echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); + } +} +else +{ + echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); +} --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_card.php @@ -9 +9 @@ - * Copyright (C) 2011-2023 Alexandre Spangaro + * Copyright (C) 2011-2013 Alexandre Spangaro @@ -15,4 +15 @@ - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2022-2023 George Gkantinas - * Copyright (C) 2023 Nick Fragoulis - * Copyright (C) 2023 Alexandre Janniaux + * Copyright (C) 2018 Frédéric France @@ -40,2 +36,0 @@ - -// Load Dolibarr environment @@ -53,24 +48 @@ -if (isModEnabled('adherent')) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -} -if (isModEnabled('accounting')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -} -if (isModEnabled('accounting')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -} -if (isModEnabled('accounting')) { - require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -} -if (isModEnabled('eventorganization')) { - require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; -} - -if ($mysoc->country_code == 'GR') { - $u = getDolGlobalString('AADE_WEBSERVICE_USER'); - $p = getDolGlobalString('AADE_WEBSERVICE_KEY'); - $myafm = preg_replace('/\D/', '', getDolGlobalString('MAIN_INFO_TVAINTRA')); -} - - -// Load translation files required by the page +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -79,21 +51,7 @@ - -if (isModEnabled('adherent')) { - $langs->load("members"); -} -if (isModEnabled('categorie')) { - $langs->load("categories"); -} -if (isModEnabled('incoterm')) { - $langs->load("incoterm"); -} -if (isModEnabled('notification')) { - $langs->load("mails"); -} -if (isModEnabled('accounting')) { - $langs->load("products"); -} - -$error = 0; $errors = array(); - - -// Get parameters +if (!empty($conf->adherent->enabled)) $langs->load("members"); +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(); + @@ -103,19 +61,5 @@ -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); - -$dol_openinpopup = ''; -if (!empty($backtopagejsfields)) { - $tmpbacktopagejsfields = explode(':', $backtopagejsfields); - $dol_openinpopup = $tmpbacktopagejsfields[0]; -} - -$socid = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -if (empty($socid) && $action == 'view') { - $action = 'create'; -} - -$id = $socid; +$confirm = GETPOST('confirm', 'alpha'); + +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; +if (empty($socid) && $action == 'view') $action = 'create'; @@ -134,5 +78,4 @@ -if ($socid > 0) { - $object->fetch($socid); -} - -if (!($object->id > 0) && $action == 'view') { +if ($socid > 0) $object->fetch($socid); + +if (!($object->id > 0) && $action == 'view') +{ @@ -144,0 +88 @@ +$object->getCanvas($socid); @@ -147,4 +91,5 @@ -if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('thirdparty', 'card', $canvas); +if (!empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('thirdparty', 'card', $canvas); @@ -153,8 +97,0 @@ -// Permissions -$permissiontoread = $user->hasRight('societe', 'lire'); -$permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->hasRight('societe', 'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0); -$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->hasRight('societe', 'creer'); // Used by the include of actions_dellink.inc.php -$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; - @@ -162,2 +99,8 @@ -$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); - +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); + +$permissiontoread = $user->rights->societe->lire; +$permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->societe->delete || ($permissiontoadd && isset($object->status) && $object->status == 0); +$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -172,29 +115,17 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/societe/list.php'; - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - - if ($cancel) { - if (!empty($backtopageforcancel)) { - header("Location: ".$backtopageforcancel); - exit; - } elseif (!empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - $action = ''; - } - - if ($action == 'confirm_merge' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) { +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) + { + $error = 0; @@ -202,3 +133,4 @@ - $soc_origin = new Societe($db); // The thirdparty that we will delete - - if ($soc_origin_id <= 0) { + $soc_origin = new Societe($db); + + if ($soc_origin_id <= 0) + { @@ -207,2 +139,5 @@ - } else { - if (!$error && $soc_origin->fetch($soc_origin_id) < 1) { + } + else + { + if (!$error && $soc_origin->fetch($soc_origin_id) < 1) + { @@ -212,3 +147,71 @@ - if (!$error) { - $result = $object->mergeCompany($soc_origin_id); - if ($result < 0) { + + if (!$error) + { + // 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', 'twitter', 'facebook', 'linkedin', 'socialnetworks', 'url', 'barcode', + 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', + 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_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; + } + } + + // Merge categories + $static_cat = new Categorie($db); + + $custcats_ori = $static_cat->containing($soc_origin->id, 'customer', 'id'); + $custcats = $static_cat->containing($object->id, 'customer', 'id'); + $custcats = array_merge($custcats, $custcats_ori); + $object->setCategories($custcats, 'customer'); + + $suppcats_ori = $static_cat->containing($soc_origin->id, 'supplier', 'id'); + $suppcats = $static_cat->containing($object->id, 'supplier', 'id'); + $suppcats = array_merge($suppcats, $suppcats_ori); + $object->setCategories($suppcats, 'supplier'); + + // If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys. + if ($soc_origin->code_client == $object->code_client + || $soc_origin->code_fournisseur == $object->code_fournisseur + || $soc_origin->barcode == $object->barcode) + { + dol_syslog("We clean customer and supplier code so we will be able to make the update of target"); + $soc_origin->code_client = ''; + $soc_origin->code_fournisseur = ''; + $soc_origin->barcode = ''; + $soc_origin->update($soc_origin->id, $user, 0, 1, 1, 'merge'); + } + + // Update + $result = $object->update($object->id, $user, 0, 1, 1, 'merge'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); @@ -216,2 +219,83 @@ - setEventMessages($object->error, $object->errors, 'errors'); - } else { + } + + // Move links + if (!$error) + { + $objects = array( + 'Adherent' => '/adherents/class/adherent.class.php', + 'Societe' => '/societe/class/societe.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 (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + } + } + } + + // External modules should update their ones too + if (!$error) + { + $reshook = $hookmanager->executeHooks('replaceThirdparty', array( + 'soc_origin' => $soc_origin->id, + 'soc_dest' => $object->id + ), $object, $action); + + if ($reshook < 0) + { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $error++; + } + } + + + if (!$error) + { + $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id); + + // Call trigger + $result = $object->call_trigger('COMPANY_MODIFY', $user); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + // End call triggers + } + + if (!$error) + { + //We finally remove the old thirdparty + if ($soc_origin->delete($soc_origin->id, $user) < 1) + { + $error++; + } + } + + if (!$error) + { @@ -218,0 +303,7 @@ + $db->commit(); + } + else + { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors'); + $db->rollback(); @@ -224,80 +315,78 @@ - if (GETPOST('getcustomercode')) { - // We defined value code_client - $_POST["customer_code"] = "Acompleter"; - } - - if (GETPOST('getsuppliercode')) { - // We defined value code_fournisseur - $_POST["supplier_code"] = "Acompleter"; - } - - if ($action == 'set_localtax1') { - //get selected from combobox - $value = GETPOST('lt1'); - $object->fetch($socid); - $res = $object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); - } - if ($action == 'set_localtax2') { - //get selected from 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); - - $object->oldcopy = dol_clone($object, 2); - - // Fill array 'array_options' with data from update form - $extrafields->fetch_name_optionals_label($object->table_element); - - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - - if (!$error) { - $result = $object->insertExtraFields('COMPANY_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - - if ($error) { - $action = 'edit_extras'; - } - } - - // Add new or update third party - if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode')) - && ($action == 'add' || $action == 'update') && $user->hasRight('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++; - } - if (GETPOST('client', 'int') && GETPOST('client', 'int') < 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors'); - $error++; - } - if (GETPOSTISSET('fournisseur') && GETPOST('fournisseur', 'int') < 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors'); - $error++; - } - - if (isModEnabled('mailing') && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors'); - } - - if (isModEnabled('mailing') && GETPOST("private", 'int') == 1 && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 && GETPOST('contact_no_email', 'int')==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors'); - } - - if (!$error) { - if ($action == 'update') { - $ret = $object->fetch($socid); + if (GETPOST('getcustomercode')) + { + // We defined value code_client + $_POST["customer_code"] = "Acompleter"; + } + + if (GETPOST('getsuppliercode')) + { + // We defined value code_fournisseur + $_POST["supplier_code"] = "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); + + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form + $extrafields->fetch_name_optionals_label($object->table_element); + + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + + if (!$error) + { + $result = $object->insertExtraFields('COMPANY_MODIFY'); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $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++; + } + if (GETPOST('client') < 0) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors'); + $error++; + } + if (GETPOST('fournisseur') < 0) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors'); + $error++; + } + + if (!$error) + { + if ($action == 'update') + { + $ret = $object->fetch($socid); @@ -305,96 +394,78 @@ - } else { - $object->canvas = $canvas; - } - - if (GETPOST("private", 'int') == 1) { // Ask to create a contact - $object->particulier = GETPOST("private", 'int'); - - $object->name = dolGetFirstLastname(GETPOST('firstname', 'alphanohtml'), GETPOST('name', 'alphanohtml')); - $object->civility_id = GETPOST('civility_id', 'alphanohtml'); // Note: civility id is a code, not an int - // Add non official properties - $object->name_bis = GETPOST('name', 'alphanohtml'); - $object->firstname = GETPOST('firstname', 'alphanohtml'); - } else { - $object->name = GETPOST('name', 'alphanohtml'); - } - $object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity); - $object->name_alias = GETPOST('name_alias', 'alphanohtml'); - $object->parent = GETPOSTISSET('parent_company_id') ? GETPOST('parent_company_id', 'int') : $object->parent; - $object->address = GETPOST('address', 'alphanohtml'); - $object->zip = GETPOST('zipcode', 'alphanohtml'); - $object->town = GETPOST('town', 'alphanohtml'); - $object->country_id = GETPOST('country_id', 'int'); - $object->state_id = GETPOST('state_id', 'int'); - - $object->socialnetworks = array(); - if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - - $object->phone = GETPOST('phone', 'alpha'); - $object->fax = GETPOST('fax', 'alpha'); - $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); - $object->no_email = GETPOST("no_email", "int"); - $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); - $object->idprof1 = trim(GETPOST('idprof1', 'alphanohtml')); - $object->idprof2 = trim(GETPOST('idprof2', 'alphanohtml')); - $object->idprof3 = trim(GETPOST('idprof3', 'alphanohtml')); - $object->idprof4 = trim(GETPOST('idprof4', 'alphanohtml')); - $object->idprof5 = trim(GETPOST('idprof5', 'alphanohtml')); - $object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml')); - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->code_client = GETPOSTISSET('customer_code') ? GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); - $object->code_fournisseur = GETPOSTISSET('supplier_code') ? GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); - $object->capital = GETPOST('capital', 'alphanohtml'); - $object->barcode = GETPOST('barcode', 'alphanohtml'); - - $object->tva_intra = GETPOST('tva_intra', 'alphanohtml'); - $object->tva_assuj = GETPOST('assujtva_value', 'alpha'); - $object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0; - $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', 'int'); - - $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type - - $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'); - - if (GETPOSTISSET('accountancy_code_sell')) { - $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - - if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { - $object->accountancy_code_sell = ''; - } else { - $object->accountancy_code_sell = $accountancy_code_sell; - } - } - if (GETPOSTISSET('accountancy_code_buy')) { - $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - - if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { - $object->accountancy_code_buy = ''; - } else { - $object->accountancy_code_buy = $accountancy_code_buy; - } - } + } + else $object->canvas = $canvas; + + if (GETPOST("private", 'int') == 1) // Ask to create a contact + { + $object->particulier = GETPOST("private", 'int'); + + $object->name = dolGetFirstLastname(GETPOST('firstname', 'alphanohtml'), GETPOST('name', 'alphanohtml')); + $object->civility_id = GETPOST('civility_id', 'alphanohtml'); // Note: civility id is a code, not an int + // Add non official properties + $object->name_bis = GETPOST('name', 'alphanohtml'); + $object->firstname = GETPOST('firstname', 'alphanohtml'); + } + else + { + $object->name = GETPOST('name', 'alphanohtml'); + } + $object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity); + $object->name_alias = GETPOST('name_alias', 'alphanohtml'); + $object->address = GETPOST('address', 'alphanohtml'); + $object->zip = GETPOST('zipcode', 'alphanohtml'); + $object->town = GETPOST('town', 'alphanohtml'); + $object->country_id = GETPOST('country_id', 'int'); + $object->state_id = GETPOST('state_id', 'int'); + //$object->skype = GETPOST('skype', 'alpha'); + //$object->twitter = GETPOST('twitter', 'alpha'); + //$object->facebook = GETPOST('facebook', 'alpha'); + //$object->linkedin = GETPOST('linkedin', 'alpha'); + $object->socialnetworks = array(); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $object->phone = GETPOST('phone', 'alpha'); + $object->fax = GETPOST('fax', 'alpha'); + $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); + $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); + $object->idprof1 = trim(GETPOST('idprof1', 'alphanohtml')); + $object->idprof2 = trim(GETPOST('idprof2', 'alphanohtml')); + $object->idprof3 = trim(GETPOST('idprof3', 'alphanohtml')); + $object->idprof4 = trim(GETPOST('idprof4', 'alphanohtml')); + $object->idprof5 = trim(GETPOST('idprof5', 'alphanohtml')); + $object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml')); + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha'); + $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha'); + $object->capital = GETPOST('capital', 'alphanohtml'); + $object->barcode = GETPOST('barcode', 'alphanohtml'); + + $object->tva_intra = GETPOST('tva_intra', 'alphanohtml'); + $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', 'int'); + + $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type + + $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'); @@ -403 +474,2 @@ - if (isModEnabled('incoterm')) { + if (!empty($conf->incoterm->enabled)) + { @@ -409 +481,2 @@ - if (isModEnabled("multicurrency")) { + if (!empty($conf->multicurrency->enabled)) + { @@ -413,4 +486,5 @@ - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) { - $error++; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) + { + $error++; @@ -421 +495,2 @@ - if ($ret < 0) { + if ($ret < 0) + { @@ -426,65 +501,57 @@ - if (!empty($_FILES['photo']['name'])) { - $current_logo = $object->logo; - $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); - } - - // Check parameters - if (!GETPOST('cancel', 'alpha')) { - if (!empty($object->email) && !isValidEMail($object->email)) { - $langs->load("errors"); - $error++; - setEventMessages($langs->trans("ErrorBadEMail", $object->email), null, 'errors'); - } - if (!empty($object->url) && !isValidUrl($object->url)) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); - } - 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); - } - } - - // We set country_id, country_code and country for the selected country - $object->country_id = GETPOST('country_id', 'int') != '' ? GETPOST('country_id', 'int') : $mysoc->country_id; - if ($object->country_id) { - $tmparray = getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; - } - } - } - - if (!$error) { - if ($action == 'add') { - $error = 0; - - $db->begin(); - - if (empty($object->client)) { - $object->code_client = ''; - } - if (empty($object->fournisseur)) { - $object->code_fournisseur = ''; - } - - $result = $object->create($user); - - if ($result >= 0 && isModEnabled('mailing') && !empty($object->email) && $object->no_email == 1) { - // Add mass emailing flag into table mailing_unsubscribe - $resultnoemail = $object->setNoEmail($object->no_email); - if ($resultnoemail < 0) { - $error++; - $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); - $action = 'create'; - } - } - - if ($result >= 0) { - if ($object->particulier) { + if (GETPOST('deletephoto')) $object->logo = ''; + elseif (!empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']); + + // Check parameters + if (!GETPOST('cancel', 'alpha')) + { + if (!empty($object->email) && !isValidEMail($object->email)) + { + $langs->load("errors"); + $error++; + setEventMessages('', $langs->trans("ErrorBadEMail", $object->email), 'errors'); + } + if (!empty($object->url) && !isValidUrl($object->url)) + { + $langs->load("errors"); + setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + } + 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); + } + } + + // 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']; + } + } + } + + if (!$error) + { + if ($action == 'add') + { + $error = 0; + + $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) + { @@ -492,4 +559,3 @@ - $contcats = GETPOST('contcats', 'array'); - $no_email = GETPOST('contact_no_email', 'int'); - $result = $object->create_individual($user, $no_email, $contcats); - if ($result < 0) { + $result = $object->create_individual($user); + if ($result < 0) + { @@ -503,2 +569,3 @@ - $result = $object->setSalesRep($salesreps, true); - if ($result < 0) { + $result = $object->setSalesRep($salesreps); + if ($result < 0) + { @@ -512 +579,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -520 +588,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -525,18 +594,37 @@ - // 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); - } - } + // 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; @@ -544,13 +632,7 @@ - } 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; - } - } - } else { - if ($result == -3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors)) { + } + // 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 + { @@ -557,0 +640 @@ + $object->code_fournisseur = null; @@ -561,103 +644,62 @@ - if ($result == -3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors)) { - $duplicate_code_error = true; - $object->code_fournisseur = null; - } - - 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; - } - - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - - if ($result >= 0 && !$error) { - $db->commit(); - - if ($backtopagejsfields) { - llxHeader('', '', ''); - - $retstring = ''; - print $retstring; - - llxFooter(); - exit; - } - - if (!empty($backtopage)) { - $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation - if (preg_match('/\?/', $backtopage)) { - $backtopage .= '&socid='.$object->id; // Old method - } - header("Location: ".$backtopage); - exit; - } else { - $url = $_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method - if (($object->client == 1 || $object->client == 3) && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) { - $url = DOL_URL_ROOT."/comm/card.php?socid=".$object->id; - } elseif ($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') { - $error = 0; - - if (GETPOST('cancel', 'alpha')) { - 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) { - // Update mass emailing flag into table mailing_unsubscribe - if (GETPOSTISSET('no_email') && $object->email) { - $no_email = GETPOST('no_email', 'int'); - $result = $object->setNoEmail($no_email); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } - } - - $action = 'view'; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } - - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + + if ($result >= 0 && !$error) + { + $db->commit(); + + if (!empty($backtopage)) + { + $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation + if (preg_match('/\?/', $backtopage)) $backtopage .= '&socid='.$object->id; // Old method + header("Location: ".$backtopage); + exit; + } + else + { + $url = $_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method + if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url = DOL_URL_ROOT."/comm/card.php?socid=".$object->id; + elseif ($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') + { + $error = 0; + + if (GETPOST('cancel', 'alpha')) + { + 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) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } @@ -668 +710,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -674 +717,2 @@ - if (!$error && $user->hasRight('categorie', 'lire')) { + if (!$error && !empty($user->rights->categorie->lire)) + { @@ -678 +722,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -686 +731,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -692,42 +738,58 @@ - // 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->logo) { - $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) { - if ($current_logo != $object->logo) { - $fileimg = $dir.'/'.$current_logo; - $dirthumbs = $dir.'/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - } - - 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); - - // Index file in database - if (getDolGlobalString('THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir - deleteFilesIntoDatabaseIndex(dirname($newfile), '', ''); - // now we index the uploaded logo file - addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1); - } - } - } - } else { - $errors[] = "ErrorBadImageFormat"; + // 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->logo) + { + $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 thumbs + $object->addThumbs($newfile); + + // Index file in database + if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir + deleteFilesIntoDatabaseIndex(dirname($newfile), '', ''); + // now we index the uploaded logo file + addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1); + } + } + } + } + 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; @@ -735,41 +797,84 @@ - } 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; - } - } - // Company logo management - - - // Update linked member - if (!$error && $object->fk_soc > 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql .= " SET fk_soc = NULL WHERE fk_soc = ".((int) $socid); - if (!$object->db->query($sql)) { - $error++; - $object->error .= $object->db->lasterror(); - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - 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"; - } - } - } else { - $action = ($action == 'add' ? 'create' : 'edit'); - } + } + // 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(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + 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"; + } + } + } + else + { + $action = ($action == 'add' ? 'create' : 'edit'); + } + } + + // Delete third party + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer) + { + $object->fetch($socid); + $object->oldcopy = clone $object; + $result = $object->delete($socid, $user); + + if ($result > 0) + { + header("Location: ".DOL_URL_ROOT."/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name)); + exit; + } + else + { + $langs->load("errors"); + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + $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')); + } + + $id = $socid; + $object->fetch($socid); + + // Selection of new fields + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) { + include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; @@ -778,66 +883,12 @@ - // Delete third party - if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'supprimer')) { - $object->fetch($socid); - $object->oldcopy = clone $object; - $result = $object->delete($socid, $user); - - if ($result > 0) { - header("Location: ".DOL_URL_ROOT."/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name)); - exit; - } else { - $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - $action = ''; - } - } - - // Set third-party type - if ($action == 'set_thirdpartytype' && $user->hasRight('societe', 'creer')) { - $object->fetch($socid); - $result = $object->setThirdpartyType(GETPOST('typent_id', 'int')); - } - - // Set incoterm - if ($action == 'set_incoterms' && $user->hasRight('societe', 'creer') && isModEnabled('incoterm')) { - $object->fetch($socid); - $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // Set parent company - if ($action == 'set_thirdparty' && $user->hasRight('societe', 'creer')) { - $object->fetch($socid); - $result = $object->setParent(GETPOST('parent_id', 'int')); - } - - // Set sales representatives - if ($action == 'set_salesrepresentatives' && $user->hasRight('societe', 'creer')) { - $object->fetch($socid); - $result = $object->setSalesRep(GETPOST('commercial', 'array')); - } - - // warehouse - if ($action == 'setwarehouse' && $user->hasRight('societe', 'creer')) { - $result = $object->setWarehouse(GETPOST('fk_warehouse', 'int')); - } - - $id = $socid; - $object->fetch($socid); - - // Selection of new fields - if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD') && (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS') || getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT'))) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - } - - // Actions to send emails - $triggersendname = '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 = !empty($conf->societe->multidir_output[$object->entity]) ? $conf->societe->multidir_output[$object->entity] : $conf->societe->dir_output; - $permissiontoadd = $user->hasRight('societe', 'creer'); - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Actions to send emails + $triggersendname = '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; + $permissiontoadd = $user->rights->societe->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -855,2 +906,5 @@ -if (isModEnabled('accounting')) { - $formaccounting = new FormAccounting($db); + +if ($socid > 0 && empty($object->id)) +{ + $result = $object->fetch($socid); + if ($result <= 0) dol_print_error('', $object->error); @@ -859,6 +913,14 @@ -if ($socid > 0 && empty($object->id)) { - $result = $object->fetch($socid); - if ($result <= 0) { - dol_print_error('', $object->error); - exit(-1); - } +$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 @@ -866,33 +928,10 @@ - -$title = $langs->trans("ThirdParty"); -if ($action == 'create') { - $title = $langs->trans("NewThirdParty"); -} -if (getDolGlobalString('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|DE:Modul_Geschäftspartner'; - -llxHeader('', $title, $help_url); - -$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - -$canvasdisplayaction = $action; -if (in_array($canvasdisplayaction, array('merge', 'confirm_merge'))) { - $canvasdisplayaction = 'view'; -} - -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- - $objcanvas->assign_values($canvasdisplayaction, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($canvasdisplayaction); // Show template -} else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- - if ($action == 'create') { - /* - * Creation - */ +else +{ + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- + if ($action == 'create') + { + /* + * Creation + */ @@ -900,2 +939,61 @@ - if (getDolGlobalString('THIRDPARTY_DEFAULT_CREATE_CONTACT') && !GETPOSTISSET('private')) { - $private = 1; + if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !GETPOSTISSET('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; } + } + // Prospect / Customer + if (GETPOST("type") == 'c') { + if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) { + $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; + } else { + $object->client = 3; + } + } + 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', 'alphanohtml'); + $object->name_alias = GETPOST('name_alias', 'alphanohtml'); + $object->firstname = GETPOST('firstname', 'alphanohtml'); + $object->particulier = $private; + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->client = GETPOST('client', 'int') ?GETPOST('client', 'int') : $object->client; + + if (empty($duplicate_code_error)) { + $object->code_client = GETPOST('customer_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur') ? GETPOST('fournisseur', 'int') : $object->fournisseur; + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + } + else { + setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'), '', 'warnings'); @@ -903,181 +1001,94 @@ - if (empty($private)) { - $private = 0; - } - - // Load object modCodeTiers - $module = (getDolGlobalString('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 = (getDolGlobalString('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", 'aZ') != 'f') { - $object->client = -1; - if (getDolGlobalString('THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT')) { - $object->client = 3; - } - } - // Prospect / Customer - if (GETPOST("type", 'aZ') == 'c') { - if (getDolGlobalString('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) { - $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT; - } else { - $object->client = 3; - } - } - if (GETPOST("type", 'aZ') == 'p') { - $object->client = 2; - } - - if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') && $object->client == 3) { - $object->client = 1; - } - - if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && getDolGlobalString('THIRDPARTY_SUPPLIER_BY_DEFAULT')))) { - $object->fournisseur = 1; - } - - $object->name = GETPOST('name', 'alphanohtml'); - $object->name_alias = GETPOST('name_alias', 'alphanohtml'); - $object->firstname = GETPOST('firstname', 'alphanohtml'); - $object->particulier = $private; - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->client = GETPOST('client', 'int') ? GETPOST('client', 'int') : $object->client; - - if (empty($duplicate_code_error)) { - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur') ? GETPOST('fournisseur', 'int') : $object->fournisseur; - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); - } else { - setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'), null, 'warnings'); - } - - $object->address = GETPOST('address', 'alphanohtml'); - $object->zip = GETPOST('zipcode', 'alphanohtml'); - $object->town = GETPOST('town', 'alphanohtml'); - $object->state_id = GETPOST('state_id', 'int'); - - $object->socialnetworks = array(); - if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - - $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', 'alphanohtml'); - $object->barcode = GETPOST('barcode', 'alphanohtml'); - $object->idprof1 = GETPOST('idprof1', 'alphanohtml'); - $object->idprof2 = GETPOST('idprof2', 'alphanohtml'); - $object->idprof3 = GETPOST('idprof3', 'alphanohtml'); - $object->idprof4 = GETPOST('idprof4', 'alphanohtml'); - $object->idprof5 = GETPOST('idprof5', 'alphanohtml'); - $object->idprof6 = GETPOST('idprof6', 'alphanohtml'); - $object->typent_id = GETPOST('typent_id', 'int'); - $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->civility_id = GETPOST('civility_id', 'alpha'); - - $object->tva_assuj = GETPOST('assujtva_value', 'int'); - $object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0; - $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', 'alphanohtml'); - - $object->commercial_id = GETPOST('commercial_id', 'int'); - $object->default_lang = GETPOST('default_lang'); - - if (GETPOSTISSET('accountancy_code_sell')) { - $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - - if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { - $object->accountancy_code_sell = ''; - } else { - $object->accountancy_code_sell = $accountancy_code_sell; - } - } - if (GETPOSTISSET('accountancy_code_buy')) { - $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - - if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { - $object->accountancy_code_buy = ''; - } else { - $object->accountancy_code_buy = $accountancy_code_buy; - } - } - - $object->logo = (isset($_FILES['photo']) ? dol_sanitizeFileName($_FILES['photo']['name']) : ''); - - // Company logo management - $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'); - - // We set multicurrency_code if enabled - if (isModEnabled("multicurrency")) { - $object->multicurrency_code = GETPOST('multicurrency_code') ? GETPOST('multicurrency_code') : $conf->currency; - } - /* Show create form */ - - $linkback = ""; - print load_fiche_titre($langs->trans("NewThirdParty"), $linkback, 'building'); - - if (!empty($conf->use_javascript_ajax)) { - if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) { + + + $object->address = GETPOST('address', 'alphanohtml'); + $object->zip = GETPOST('zipcode', 'alphanohtml'); + $object->town = GETPOST('town', 'alphanohtml'); + $object->state_id = GETPOST('state_id', 'int'); + //$object->skype = GETPOST('skype', 'alpha'); + //$object->twitter = GETPOST('twitter', 'alpha'); + //$object->facebook = GETPOST('facebook', 'alpha'); + //$object->linkedin = GETPOST('linkedin', 'alpha'); + $object->socialnetworks = array(); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $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', 'alphanohtml'); + $object->barcode = GETPOST('barcode', 'alphanohtml'); + $object->idprof1 = GETPOST('idprof1', 'alphanohtml'); + $object->idprof2 = GETPOST('idprof2', 'alphanohtml'); + $object->idprof3 = GETPOST('idprof3', 'alphanohtml'); + $object->idprof4 = GETPOST('idprof4', 'alphanohtml'); + $object->idprof5 = GETPOST('idprof5', 'alphanohtml'); + $object->idprof6 = GETPOST('idprof6', 'alphanohtml'); + $object->typent_id = GETPOST('typent_id', 'int'); + $object->effectif_id = GETPOST('effectif_id', 'int'); + $object->civility_id = GETPOST('civility_id', 'alpha'); + + $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', 'alphanohtml'); + + $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, 'building'); + + if (!empty($conf->use_javascript_ajax)) { + if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) { @@ -1097 +1107,0 @@ - $("#typent_id").change(); @@ -1099 +1108,0 @@ - $("#effectif_id").change(); @@ -1106 +1114,0 @@ - $("#typent_id").change(); @@ -1108,5 +1115,0 @@ - $("#effectif_id").change(); - /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */ - if ($("#civility_id").data("select2")) { - $("#civility_id").select2({width: "resolve"}); - } @@ -1115,10 +1118,16 @@ - });'; - - if (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) { - print ' - function init_check_no_email(input) { - if (input.val()!="") { - $(".noemail").addClass("fieldrequired"); - } else { - $(".noemail").removeClass("fieldrequired"); - } + }); + + init_customer_categ(); + $("#customerprospect").change(function() { + init_customer_categ(); + }); + function init_customer_categ() { + console.log("is customer or prospect = "+jQuery("#customerprospect").val()); + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').')) + { + jQuery(".visibleifcustomer").hide(); + } + else + { + jQuery(".visibleifcustomer").show(); + } @@ -1126,2 +1135,4 @@ - $("#email").keyup(function() { - init_check_no_email($(this)); + + init_supplier_categ(); + $("#fournisseur").change(function() { + init_supplier_categ(); @@ -1129,3 +1140,17 @@ - init_check_no_email($("#email"));'; - } - print '});'; + function init_supplier_categ() { + console.log("is supplier = "+jQuery("#fournisseur").val()); + if (jQuery("#fournisseur").val() == 0) + { + jQuery(".visibleifsupplier").hide(); + } + else + { + jQuery(".visibleifsupplier").show(); + } + } + + $("#selectcountry_id").change(function() { + document.formsoc.action.value="create"; + document.formsoc.submit(); + }); + });'; @@ -1153,70 +1177,0 @@ - } - - print ''."\n"; - } - - dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); - - print '
'; // Chrome ignor autocomplete - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { - print ''; - } - - print dol_get_fiche_head(null, 'card', '', 0, ''); - - // Call Hook tabContentCreateThirdparty - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentCreateThirdparty', $parameters, $object, $action); - if (empty($reshook)) { - print ''; - - // Name, firstname - print ''; - - print ''; - print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); // For some countries that need the company name in 2 languages - // This implementation of the feature to search already existing company has been disabled. It must be implemented by keeping the "input text" and we must call the search ajax societe/ajax/ajaxcompanies.php - // on a keydown of the input. We should show data about a duplicate found if we found less than 5 answers into a div under the input. - /* - print ''; - print "\n".' - '; - */ - print ''; - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''; - } - print ''; - - // If javascript on, we show option individual - if ($conf->use_javascript_ajax) { - if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) { - // Firstname - print ''; - print ''; - print ''; - - // Title - print ''; - print ''; - } - } - - // Alias names (commercial, trademark or alias names) - print ''; - print ''; - - // Prospect/Customer - print ''; - print ''; - - if ($conf->browser->layout == 'phone') { - print ''; - } - - print ''; - - if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire')) - || (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) { - // Supplier - print ''; - print ''; - - - if ($conf->browser->layout == 'phone') { - print ''; - } - - print ''; - } - - // Status - print ''; - - // Barcode - if (isModEnabled('barcode')) { - print ''; - print ''; - } - - // Address - print ''; - print ''; - - // Zip / Town - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - - // Country - print ''; - - // State - if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) { - if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) { - print ''; - } - - // Phone / Fax - print ''; - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' '; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' '; - - // Email / Web - print ''; - print 'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' '; - if (isModEnabled('mailing') && getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) { - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - print ''; - } - print ''; - print ''; - print ''; - - // Unsubscribe - if (isModEnabled('mailing')) { - if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) { - print "\n".''."\n"; - } - if (!GETPOSTISSET("no_email") && !empty($object->email)) { - $result = $object->getNoEmail(); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - print ''; - print ''; - print ''; - print ''; - } - - // Social networks - if (isModEnabled('socialnetworks')) { - $object->showSocialNetwork($socialnetworks, ($conf->browser->layout == 'phone' ? 2 : 4)); - } - - // Prof ids - $i = 1; - $j = 0; - $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2); - while ($i <= 6) { - $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof != '-') { - $key = 'idprof'.$i; - - if (($j % $NBCOLS) == 0) { - print ''; - } - - $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; - print ''; - if (($j % $NBCOLS) == ($NBCOLS - 1)) { - print ''; - } - $j++; - } - $i++; - } - if ($NBCOLS > 1 && ($j % 2 == 1)) { - print ''; - } - - // Vat is used - print ''; - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - print ''; - print ''; - - // VAT reverse charge by default - if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { - 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 ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - } elseif ($mysoc->localtax1_assuj == "1") { - print ''; - } elseif ($mysoc->localtax2_assuj == "1") { - print ''; - } - - // Type - Workforce/Staff - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - - // Legal Form - print ''; - print ''; - - // Capital - print ''; - print ''; - } else { - print ''.$langs->trans("Currency".$conf->currency).''; - } - if (getDolGlobalInt('MAIN_MULTILANGS')) { - print ''; - print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; - print ''; - } - - // Categories - if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { - $langs->load('categories'); - - // Customer - print '"; - - if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) { - print '"; - } - - // Supplier - if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) { - print '"; - } - } - - // Multicurrency - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - - // Other attributes - $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - - // Parent company - if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY')) { - print ''; - print ''; - print ''; - } - - // Assign a sale representative - print ''; - print ''; - print ''; - - // Add logo - print ''; - print ''; - print ''; - print ''; - - print '
'; - if ($object->particulier || $private) { - print ''.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName', 'name').''; @@ -1224,561 +1179,8 @@ - print ''.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0).''; - } - print ''.$langs->trans('Prefix').'
'.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).'
'.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).''; - print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; - $selected = (GETPOSTISSET('client') ? GETPOST('client', 'int') : $object->client); - print $formcompany->selectProspectCustomerType($selected); - print '
'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; - 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 '
'.$form->editfieldkey('Vendor', 'fournisseur', '', $object, 0, 'string', '', 1).''; - $default = -1; - if (getDolGlobalString('THIRDPARTY_SUPPLIER_BY_DEFAULT')) { - $default = 1; - } - print $form->selectyesno("fournisseur", (GETPOST('fournisseur', 'int') != '' ? GETPOST('fournisseur', 'int') : (GETPOST("type", 'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type", 'alpha') == '' ? 1 : 0), 1); - print '
'; - if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { - print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0); - } - print ''; - if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { - 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 '
'.$form->editfieldkey('Status', 'status', '', $object, 0).''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1); - print '
'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; - print img_picto('', 'barcode', 'class="pictofixedwidth"'); - print ''; - print '
'; - print $form->editfieldkey('Address', 'address', '', $object, 0); - print ''; - print ''; - print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); - print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); - print '
'.$form->editfieldkey('Town', 'town', '', $object, 0).''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth150 quatrevingtpercent'); - print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); - print '
'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).''; - print img_picto('', 'country', 'class="pictofixedwidth"'); - print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 maxwidth500 widthcentpercentminusx'); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print '
'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; - } else { - print '
'.$form->editfieldkey('State', 'state_id', '', $object, 0).''; - } - - if ($object->country_id) { - print img_picto('', 'state', 'class="pictofixedwidth"'); - print $formcompany->select_state($object->state_id, $object->country_code); - } else { - print $countrynotdefined; - } - print '
'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', !getDolGlobalString('SOCIETE_EMAIL_MANDATORY') ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'
'.$form->editfieldkey($langs->trans('No_Email') .' ('.$langs->trans('Contact').')', 'contact_no_email', '', $object, 0).'browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.$form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($object->no_email) ? 0 : 1)), 1, false, 1).'
'.$form->editfieldkey('Web', 'url', '', $object, 0).''.img_picto('', 'globe', 'class="pictofixedwidth"').'
'; - print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2)); - print '
'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).''; - - print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); - print '
'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; - print ''; // Assujeti par defaut en creation - print '
'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; - $s = ''; - - if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) { - $s .= ' '; - - if (!empty($conf->use_javascript_ajax)) { - $widthpopup = 600; - if (!empty($conf->dol_use_jmobile)) { - $widthpopup = 350; - } - $heightpopup = 400; - print "\n"; - print ''; - print "\n"; - $s .= ''.$langs->trans("VATIntraCheck").''; - $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); - } else { - $s .= 'country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; - } - } - print $s; - print '
' . $form->editfieldkey('VATReverseChargeByDefault', 'vat_reverse_charge', '', $object, 0) . ''; - print 'vat_reverse_charge == '1' ? ' checked' : '').'>'; - print '
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; - print 'global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? 'checked="checked"' : '') . ' value="1">'; - print '
'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; - print 'global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? 'checked="checked"' : '') . ' value="1">'; - print '
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; - print 'global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? 'checked="checked"' : '') . ' value="1">'; - print '
'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).''; - print 'global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? 'checked="checked"' : '') . ' value="1">'; - print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'."\n"; - $sortparam = (!getDolGlobalString('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, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); - if ($user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - if (!getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) { - print '
'.$form->editfieldkey('Workforce', 'effectif_id', '', $object, 0).'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; - print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0, '', 0, 0, 0, '', '', 1); - if ($user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - } else { - print ''; - } - print '
'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; - if ($object->country_id) { - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); - } else { - print $countrynotdefined; - } - print '
'.$form->editfieldkey('Capital', 'capital', '', $object, 0).' '; - if (isModEnabled("multicurrency")) { - print ''.$langs->trans("Currency".$object->multicurrency_code).'
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); - print '
'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); - print '
'.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print "
'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, 'parent', null, null, 1); - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print "
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print "
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print img_picto('', 'currency', 'class="pictofixedwidth"'); - print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)), 'multicurrency_code', 1, '', false, 'maxwidth150 widthcentpercentminusx'); - print '
'.$langs->trans('ParentCompany').''; - print img_picto('', 'company', 'class="paddingrightonly"'); - print $form->select_company(GETPOST('parent_company_id'), 'parent_company_id', '', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); - print '
'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; - $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'AND u.statut = 1', 0, '', '', 0, 2); - // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record. - $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : array($user->id))); - print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print '
'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; - print ''; - print '
'."\n"; - - // Accountancy codes - if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) { - print ''; - - if (isModEnabled('accounting')) { - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_buy - print ''; - print ''; - } else { // For external software - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_buy - print ''; - print ''; - } - - print '
'.$langs->trans("ProductAccountancySellCode").''; - $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, ''); - print '
'.$langs->trans("ProductAccountancyBuyCode").''; - $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, ''); - print '
'.$langs->trans("ProductAccountancySellCode").''; - print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print '
'; + print ''."\n"; @@ -1788,47 +1190,452 @@ - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("AddThirdParty", 'Cancel', null, 0, '', $dol_openinpopup); - - print '
'."\n"; - } elseif ($action == 'edit') { - //print load_fiche_titre($langs->trans("EditCompany")); - - if ($socid) { - $res = $object->fetch_optionals(); - //if ($res < 0) { dol_print_error($db); exit; } - - $head = societe_prepare_head($object); - - // Load object modCodeTiers - $module = (getDolGlobalString('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 check if the prefix tag 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); - // We check if the prefix tag is used - if ($modCodeFournisseur->code_auto) { - $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); - } + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); + + print '
'; // Chrome ignor autocomplete + + 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 ''; + print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300'); + 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) + { + if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) + { + // Firstname + print ''; + print ''; + print ''; + + // Title + print ''; + print ''; + } + } + + // Alias names (commercial, trademark or alias names) + print ''; + print ''; + + // Prospect/Customer + print ''; + print ''; + + if ($conf->browser->layout == 'phone') print ''; + + print ''; + + if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) + { + // Supplier + print ''; + print ''; + + + if ($conf->browser->layout == 'phone') print ''; + + print ''; + } + + // Status + print ''; + + // Barcode + if (!empty($conf->barcode->enabled)) + { + print ''; + print ''; + } + + // Address + print ''; + print ''; + + // Zip / Town + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + + // Country + print ''; + + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print ''; + } + + // Phone / Fax + print ''; + print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'.img_picto('', 'object_phoning').' '; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'.img_picto('', 'object_phoning_fax').' '; + + // Email / Web + print ''; + print ''; + print ''; + print ''; + + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + } + + // Prof ids + $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2); + while ($i <= 6) + { + $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + if ($idprof != '-') + { + $key = 'idprof'.$i; + + if (($j % $NBCOLS) == 0) print ''; + + $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; + print ''; + if (($j % $NBCOLS) == ($NBCOLS - 1)) print ''; + $j++; + } + $i++; + } + if ($NBCOLS > 1 && ($j % 2 == 1)) print ''; + + // Vat is used + print ''; + print ''; + if ($conf->browser->layout == 'phone') 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 ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + } + elseif ($mysoc->localtax1_assuj == "1") + { + print ''; + } + elseif ($mysoc->localtax2_assuj == "1") + { + print ''; + } + + // Type - Size + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + + // Legal Form + print ''; + print ''; + + // Capital + print ''; + print ''; + + if (!empty($conf->global->MAIN_MULTILANGS)) + { + 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 || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { + print '"; + //} + + // Supplier + //if ($object->fournisseur) { + 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_add.tpl.php'; + + // Assign a sale representative + print ''; + print ''; + print ''; + + // Ajout du logo + print ''; + print ''; + print ''; + print ''; + + print '
'; + if ($object->particulier || $private) + { + print ''.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName', 'name').''; + } + else + { + print ''.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0).''; + } + print ''.$langs->trans('Prefix').'
'.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).'
'.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).''; + print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; + $selected = (GETPOSTISSET('client') ?GETPOST('client', 'int') : $object->client); + print $formcompany->selectProspectCustomerType($selected); + print '
'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; + 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 '
'.$form->editfieldkey('Vendor', 'fournisseur', '', $object, 0, 'string', '', 1).''; + $default = -1; + if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default = 1; + print $form->selectyesno("fournisseur", (GETPOST('fournisseur', 'int') != '' ? GETPOST('fournisseur', 'int') : (GETPOST("type", 'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type", 'alpha') == '' ? 1 : 0)); + print '
'; + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + { + print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0); + } + print ''; + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + { + 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 '
'.$form->editfieldkey('Status', 'status', '', $object, 0).''; + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); + print '
'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; + print '
'; + print $form->editfieldkey('Address', 'address', '', $object, 0); + print ''; + print ''; + print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent'); + print '
'.$form->editfieldkey('Town', 'town', '', $object, 0).''; + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent'); + print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); + print '
'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).''; + print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print $form->select_country((GETPOST('country_id') != '' ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 widthcentpercentminusx'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; + } + else + { + print '
'.$form->editfieldkey('State', 'state_id', '', $object, 0).''; + } + + if ($object->country_id) print $formcompany->select_state($object->state_id, $object->country_code); + else print $countrynotdefined; + print '
'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'
'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'
'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).''.img_picto('', 'object_email').'
'.$form->editfieldkey('Web', 'url', '', $object, 0).''.img_picto('', 'globe').'
'; + print ''; + print '
'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).''; + + print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); + print '
'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; + print $form->selectyesno('assujtva_value', GETPOSTISSET('assujtva_value') ?GETPOST('assujtva_value', 'int') : 1, 1); // Assujeti par defaut en creation + print '
'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; + $s = ''; + + if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) + { + $s .= ' '; + + if (!empty($conf->use_javascript_ajax)) + { + $widthpopup = 600; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; + $heightpopup = 400; + print "\n"; + print ''; + print "\n"; + $s .= ''.$langs->trans("VATIntraCheck").''; + $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("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 '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' ? ' colspan="3"': '').'>'."\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 '
'.$form->editfieldkey('Staff', 'effectif_id', '', $object, 0).'browser->layout == 'phone' ? ' colspan="3"': '').'>'; + print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id); + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; + if ($object->country_id) + { + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + } + else + { + print $countrynotdefined; + } + print '
'.$form->editfieldkey('Capital', 'capital', '', $object, 0).' '; + print ''.$langs->trans("Currency".$conf->currency).'
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; + print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); + print '
'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); + print '
'.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).''; + $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 "
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; + $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 "
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); + print '
'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); + // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record. + $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array()))); + print $form->multiselectarray('commercial', $userlist, $selected, null, null, null, null, "90%"); + print '
'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; + print ''; + print '
'."\n"; + + dol_fiche_end(); + + print '
'; + print ''; + if (!empty($backtopage)) + { + print '     '; + print ''; + } + else + { + print '     '; + print ''; + } + print '
'."\n"; + + print '
'."\n"; + } + elseif ($action == 'edit') + { + //print load_fiche_titre($langs->trans("EditCompany")); + + if ($socid) + { + $res = $object->fetch_optionals(); + //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(); + } @@ -1838,70 +1645,50 @@ - if (GETPOSTISSET('name')) { - // We overwrite with values if posted - $object->name = GETPOST('name', 'alphanohtml'); - $object->name_alias = GETPOST('name_alias', 'alphanohtml'); - $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); - $object->client = GETPOST('client', 'int'); - $object->code_client = GETPOST('customer_code', 'alpha'); - $object->fournisseur = GETPOST('fournisseur', 'int'); - $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); - $object->address = GETPOST('address', 'alphanohtml'); - $object->zip = GETPOST('zipcode', 'alphanohtml'); - $object->town = GETPOST('town', 'alphanohtml'); - $object->country_id = GETPOST('country_id') ? GETPOST('country_id', 'int') : $mysoc->country_id; - $object->state_id = GETPOST('state_id', 'int'); - $object->parent = GETPOST('parent_company_id', 'int'); - - $object->socialnetworks = array(); - if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { - $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); - } - } - } - - $object->phone = GETPOST('phone', 'alpha'); - $object->fax = GETPOST('fax', 'alpha'); - $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); - $object->no_email = GETPOST("no_email", "int"); - $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL); - $object->capital = GETPOST('capital', 'alphanohtml'); - $object->idprof1 = GETPOST('idprof1', 'alphanohtml'); - $object->idprof2 = GETPOST('idprof2', 'alphanohtml'); - $object->idprof3 = GETPOST('idprof3', 'alphanohtml'); - $object->idprof4 = GETPOST('idprof4', 'alphanohtml'); - $object->idprof5 = GETPOST('idprof5', 'alphanohtml'); - $object->idprof6 = GETPOST('idprof6', 'alphanohtml'); - $object->typent_id = GETPOST('typent_id', 'int'); - $object->effectif_id = GETPOST('effectif_id', 'int'); - $object->barcode = GETPOST('barcode', 'alphanohtml'); - $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int'); - $object->default_lang = GETPOST('default_lang', 'alpha'); - - $object->tva_assuj = GETPOST('assujtva_value', 'int'); - $object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0; - $object->tva_intra = GETPOST('tva_intra', 'alphanohtml'); - $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'); - - if (GETPOSTISSET('accountancy_code_sell')) { - $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); - - if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { - $object->accountancy_code_sell = ''; - } else { - $object->accountancy_code_sell = $accountancy_code_sell; - } - } - if (GETPOSTISSET('accountancy_code_buy')) { - $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); - - if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') { - $object->accountancy_code_buy = ''; - } else { - $object->accountancy_code_buy = $accountancy_code_buy; - } - } + if (GETPOSTISSET('name')) + { + // We overwrite with values if posted + $object->name = GETPOST('name', 'alphanohtml'); + $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml'); + $object->client = GETPOST('client', 'int'); + $object->code_client = GETPOST('customer_code', 'alpha'); + $object->fournisseur = GETPOST('fournisseur', 'int'); + $object->code_fournisseur = GETPOST('supplier_code', 'alpha'); + $object->address = GETPOST('address', 'alphanohtml'); + $object->zip = GETPOST('zipcode', 'alphanohtml'); + $object->town = GETPOST('town', 'alphanohtml'); + $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->twitter = GETPOST('twitter', 'alpha'); + //$object->facebook = GETPOST('facebook', 'alpha'); + //$object->linkedin = GETPOST('linkedin', 'alpha'); + $object->socialnetworks = array(); + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { + $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml'); + } + } + } + $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', 'alphanohtml'); + $object->idprof1 = GETPOST('idprof1', 'alphanohtml'); + $object->idprof2 = GETPOST('idprof2', 'alphanohtml'); + $object->idprof3 = GETPOST('idprof3', 'alphanohtml'); + $object->idprof4 = GETPOST('idprof4', 'alphanohtml'); + $object->idprof5 = GETPOST('idprof5', 'alphanohtml'); + $object->idprof6 = GETPOST('idprof6', 'alphanohtml'); + $object->typent_id = GETPOST('typent_id', 'int'); + $object->effectif_id = GETPOST('effectif_id', 'int'); + $object->barcode = GETPOST('barcode', 'alphanohtml'); + $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', 'alphanohtml'); + $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'); @@ -1910 +1697,2 @@ - if (isModEnabled('incoterm')) { + if (!empty($conf->incoterm->enabled)) + { @@ -1915,34 +1703,27 @@ - //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']; - } - - // We set multicurrency_code if enabled - if (isModEnabled("multicurrency")) { - $object->multicurrency_code = GETPOST('multicurrency_code') ? GETPOST('multicurrency_code') : $object->multicurrency_code; - } - } - - if ($object->localtax1_assuj == 0) { - $sub = 0; - } else { - $sub = 1; - } - if ($object->localtax2_assuj == 0) { - $sub2 = 0; - } else { - $sub2 = 1; - } - - if (!empty($conf->use_javascript_ajax)) { - print "\n".''."\n"; + print ''."\n"; + } + + print '
'; + 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 ''; @@ -2025,7 +1825,360 @@ - print ''; - print ''; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) { - 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 ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + + // Supplier + if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) + { + print ''; + print ''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + } + + // Barcode + if (!empty($conf->barcode->enabled)) + { + print ''; + print ''; + } + + // Status + print ''; + + // Address + print ''; + print ''; + + // Zip / Town + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + + // Country + print ''; + + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) + { + if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) + { + print ''; + } + + // Phone / Fax + print ''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + print ''; + + // EMail / Web + print ''; + print ''; + print ''; + print ''; + + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + } + + // Prof ids + $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2); + while ($i <= 6) + { + $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); + if ($idprof != '-') + { + $key = 'idprof'.$i; + + if (($j % $NBCOLS) == 0) print ''; + + $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; + print ''; + if (($j % $NBCOLS) == ($NBCOLS - 1)) print ''; + $j++; + } + $i++; + } + if ($NBCOLS > 0 && $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 ''; + if ($conf->browser->layout == 'phone') 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 ''; + if ($conf->browser->layout == 'phone') print ''; + print ''; + + // Juridical type + print ''; + + // Capital + print ''; + print ''; + + // Default language + if (!empty($conf->global->MAIN_MULTILANGS)) + { + print ''; + print ''; + } + + // Incoterms + if (!empty($conf->incoterm->enabled)) + { + print ''; + print ''; + print ''; + } + + // Categories + if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) + { + // Customer + print ''; + print '"; + + // Supplier + print ''; + print '"; @@ -2034,494 +2187,3 @@ - - print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); - - print '
'; - // Call Hook tabContentEditThirdparty - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentEditThirdparty', $parameters, $object, $action); - if (empty($reshook)) { - print '
'.$langs->trans("ID").''; + print $object->ref; + print '
'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).''; + print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300'); + print '
'.$form->editfieldkey('Prefix', 'prefix', '', $object, 0).''; + // 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 '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; + print $formcompany->selectProspectCustomerType($object->client); + print '
'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; + + 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 ''; + } + elseif ($object->codeclient_modifiable()) + { + print ''; + } + else + { + print $object->code_client; + print ''; + } + print ''; + $s = $modCodeClient->getToolTip($langs, $object, 0); + print $form->textwithpicto('', $s, 1); + print '
'; + + print '
'.$form->editfieldkey('Supplier', 'fournisseur', '', $object, 0, 'string', '', 1).''; + print $form->selectyesno("fournisseur", $object->fournisseur, 1); + print '
'; + if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + { + print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0); + } + print ''; + 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 ''; + } + elseif ($object->codefournisseur_modifiable()) + { + print ''; + } + else + { + print $object->code_fournisseur; + print ''; + } + print ''; + $s = $modCodeFournisseur->getToolTip($langs, $object, 1); + print $form->textwithpicto('', $s, 1); + print '
'; + print '
'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; + print '
'.$form->editfieldkey('Status', 'status', '', $object, 0).''; + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); + print '
'.$form->editfieldkey('Address', 'address', '', $object, 0).''; + print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth50onsmartphone'); + print '
'.$form->editfieldkey('Town', 'town', '', $object, 0).''; + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); + print '
'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; + print img_picto('', 'globe-americas', 'class="paddingrightonly"'); + print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 widthcentpercentminusx'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; + } + else + { + print '
'.$form->editfieldkey('State', 'state_id', '', $object, 0).''; + } + + print $formcompany->select_state($object->state_id, $object->country_code); + print '
'.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).''.img_picto('', 'object_phoning').'
'.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).''.img_picto('', 'object_phoning_fax').'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''.img_picto('', 'object_email').'
'.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''.img_picto('', 'globe').'
'; + print ''; + print '
'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; + print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); + print '
'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; + print $form->selectyesno('assujtva_value', $object->tva_assuj, 1); + print '
'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; + 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 '
'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; + 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 '
'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; + 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 '
'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; + 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 '
'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; + $s = ''; + + if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) + { + $s .= '   '; + + if ($conf->use_javascript_ajax) + { + $widthpopup = 600; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; + $heightpopup = 400; + print "\n"; + print ''; + print "\n"; + $s .= ''.$langs->trans("VATIntraCheck").''; + $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); + } + else + { + $s .= 'country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; + } + } + print $s; + print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).''; + 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 '
'.$form->editfieldkey('Staff', 'effectif_id', '', $object, 0).''; + print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print '
'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + print '
'.$form->editfieldkey('Capital', 'capital', '', $object, 0).' '.$langs->trans("Currency".$conf->currency).'
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; + print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1); + print '
'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); + print '
'.$form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0).''; + $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); + $arrayselected = array(); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print "
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; + $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); + $arrayselected = array(); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } + print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print "
'; - - // Ref/ID - if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) { - print ''; - } - - // Name - print ''; - print ''; - - // Alias names (commercial, trademark or alias names) - print ''; - print ''; - - // Prefix - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''; - } - - // Prospect/Customer - print ''; - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - - // Supplier - if (((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) - || (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) { - print ''; - print ''; - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - print ''; - } - - // Barcode - if (isModEnabled('barcode')) { - print ''; - print ''; - } - - // Status - print ''; - - // Address - print ''; - print ''; - - // Zip / Town - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100'); - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); - print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent'); - print ''; - - // Country - print ''; - - // State - if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) { - if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) { - print ''; - } - - // Phone / Fax - print ''; - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' '; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - print 'browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' '; - print ''; - - // Web - print ''; - print ''; - - // EMail - print ''; - print ''; - - // Unsubscribe - if (isModEnabled('mailing')) { - if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) { - print "\n".''."\n"; - } - if (!GETPOSTISSET("no_email") && !empty($object->email)) { - $result = $object->getNoEmail(); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - print ''; - print ''; - print ''; - print ''; - } - - // Social network - if (isModEnabled('socialnetworks')) { - $object->showSocialNetwork($socialnetworks, ($conf->browser->layout == 'phone' ? 2 : 4)); - } - - // Prof ids - $i = 1; - $j = 0; - $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2); - while ($i <= 6) { - $idprof = $langs->transcountry('ProfId'.$i, $object->country_code); - if ($idprof != '-') { - $key = 'idprof'.$i; - - if (($j % $NBCOLS) == 0) { - print ''; - } - - $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY'; - print ''; - if (($j % $NBCOLS) == ($NBCOLS - 1)) { - print ''; - } - $j++; - } - $i++; - } - if ($NBCOLS > 0 && $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 ''; - print ''; - if (!isOnlyOneLocalTax(2)) { - print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); - print ''; - } - print ''; - } elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") { - print ''; - } elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") { - print ''; - } - - // VAT reverse charge by default - if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { - print ''; - } - - // VAT Code - print ''; - print ''; - print ''; - - // Type - Workforce/Staff - print ''; - if ($conf->browser->layout == 'phone') { - print ''; - } - print ''; - - // Juridical type - print ''; - - // Capital - print ''; - print ''; - } else { - print '"> '.$langs->trans("Currency".$conf->currency).''; - } - - // Default language - if (getDolGlobalInt('MAIN_MULTILANGS')) { - print ''; - print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; - print ''; - } - - // Categories - if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { - // Customer - print ''; - print '"; - - // Supplier - if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { - print ''; - print '"; - } - } - - // Multicurrency - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - - // Other attributes - $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - // Parent company - if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY')) { - print ''; - print ''; - print ''; - } - - // Webservices url/key - if (!empty($conf->syncsupplierwebservices->enabled)) { - print ''; - print ''; - print ''; - print ''; - } - - // Logo - print ''; - print ''; - print ''; - print ''; - - // Assign sale representative + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { @@ -2529,431 +2191,3 @@ - print ''; - print ''; - - print '
'.$langs->trans("ID").''; - print $object->ref; - print '
'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).''; - print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); - print '
'.$form->editfieldkey('Prefix', 'prefix', '', $object, 0).''; - // 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 '
'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; - print $formcompany->selectProspectCustomerType($object->client); - print '
'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).''; - - 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 ''; - } elseif ($object->codeclient_modifiable()) { - print ''; - } else { - print $object->code_client; - print ''; - } - print ''; - $s = $modCodeClient->getToolTip($langs, $object, 0); - print $form->textwithpicto('', $s, 1); - print '
'; - - print '
'.$form->editfieldkey('Supplier', 'fournisseur', '', $object, 0, 'string', '', 1).''; - print $form->selectyesno("fournisseur", $object->fournisseur, 1, false, 0, 1); - print '
'; - if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { - print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0); - } - print ''; - 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 ''; - } elseif ($object->codefournisseur_modifiable()) { - print ''; - } else { - print $object->code_fournisseur; - print ''; - } - print ''; - $s = $modCodeFournisseur->getToolTip($langs, $object, 1); - print $form->textwithpicto('', $s, 1); - print '
'; - print '
'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; - print img_picto('', 'barcode'); - print ''; - print '
'.$form->editfieldkey('Status', 'status', '', $object, 0).''; - print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1); - print '
'.$form->editfieldkey('Address', 'address', '', $object, 0).''; - print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); - print '
'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'
'.$form->editfieldkey('Town', 'town', '', $object, 0).'
'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print img_picto('', 'globe-americas', 'class="paddingrightonly"'); - print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 maxwidth500 widthcentpercentminusx'); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print '
'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).''; - } else { - print '
'.$form->editfieldkey('State', 'state_id', '', $object, 0).''; - } - - print img_picto('', 'state', 'class="pictofixedwidth"'); - print $formcompany->select_state($object->state_id, $object->country_code); - print '
'.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).'
'.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'
'.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''.img_picto('', 'globe', 'class="pictofixedwidth"').'
'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalString('SOCIETE_EMAIL_MANDATORY'))).''; - print img_picto('', 'object_email', 'class="pictofixedwidth"'); - print ''; - print '
'; - $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2); - print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $object->no_email), 1, false, $useempty); - print '
'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).''; - print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code); - print '
'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; - print 'tva_assuj ? 'checked="checked"' : '') . ' value="1">'; - print '
'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; - print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; - if (!isOnlyOneLocalTax(1)) { - print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); - print ''; - } - print '
'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; - print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">
'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).''; - print 'localtax1_assuj ? 'checked="checked"' : '') . ' value="1">'; - if (!isOnlyOneLocalTax(1)) { - print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); - print ''; - } - print '
'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; - print 'localtax2_assuj ? 'checked="checked"' : '') . ' value="1">'; - if (!isOnlyOneLocalTax(2)) { - print ' '.$langs->transcountry("Type", $mysoc->country_code).': '; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); - print ''; - } - print '
' . $form->editfieldkey('VATReverseChargeByDefault', 'vat_reverse_charge', '', $object, 0) . ''; - print 'vat_reverse_charge == '1' ? ' checked' : '').'>'; - print '
'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; - $s = ''; - - if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) { - $s .= '   '; - - if ($conf->use_javascript_ajax) { - $widthpopup = 600; - if (!empty($conf->dol_use_jmobile)) { - $widthpopup = 350; - } - $heightpopup = 400; - print "\n"; - print ''; - print "\n"; - $s .= ''.$langs->trans("VATIntraCheck").''; - $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); - } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; - } - } - print $s; - print '
'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'; - print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - if (!getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) { - print '
'.$form->editfieldkey('Workforce', 'effectif_id', '', $object, 0).''; - print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0, '', 0, 0, 0, '', '', 1); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - } else { - print ''; - } - print '
'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); - print '
'.$form->editfieldkey('Capital', 'capital', '', $object, 0).' '.$langs->trans("Currency".$object->multicurrency_code).'
'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; - print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->default_lang, 'default_lang', 0, null, '1', 0, 0, 'maxwidth300 widthcentpercentminusx'); - print '
'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); - print '
'.$form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0).''; - $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); - $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; - } - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print "
'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).''; - $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); - $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; - } - print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print "
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print img_picto('', 'currency', 'class="pictofixedwidth"'); - print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)), 'multicurrency_code', 1, '', false, 'maxwidth150 widthcentpercentminusx'); - print '
'.$langs->trans('ParentCompany').''; - print img_picto('', 'company', 'class="pictofixedwidth"'); - print $form->select_company(GETPOST('parent_company_id') ? GETPOST('parent_company_id') : $object->parent, 'parent_company_id', '', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500 widthcentpercentminusxx'); - print '
'.$form->editfieldkey('WebServiceURL', 'webservices_url', '', $object, 0).''.$form->editfieldkey('WebServiceKey', 'webservices_key', '', $object, 0).'
'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; - 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("PhotoFile").'
'; - $maxfilesizearray = getMaxFileSizeArray(); - $maxmin = $maxfilesizearray['maxmin']; - if ($maxmin > 0) { - print ''; // MAX_FILE_SIZE must precede the field type=file - } - print ''; - print '
'; - } - print '
'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; - $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); - $arrayselected = GETPOST('commercial', 'array'); - if (empty($arrayselected)) { - $arrayselected = $object->getSalesRepresentatives($user, 1); - } - print img_picto('', 'user', 'class="pictofixedwidth"').$form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1); - print '
'; - - if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) { - print '
'; - print ''; - - if (isModEnabled('accounting')) { - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_buy - print ''; - print ''; - } else { // For external software - // Accountancy_code_sell - print ''; - print ''; - - // Accountancy_code_buy - print ''; - print ''; - } - print '
'.$langs->trans("ProductAccountancySellCode").''; - print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); - print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); - print '
'.$langs->trans("ProductAccountancySellCode").''; - print '
'.$langs->trans("ProductAccountancyBuyCode").''; - print '
'; - } - } - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); - - print '
'; - } - } else { - /* - * View - */ - - if (!empty($object->id)) { - $res = $object->fetch_optionals(); - } - //if ($res < 0) { dol_print_error($db); exit; } - - - $head = societe_prepare_head($object); - - print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company'); - - $formconfirm = ''; - - // Confirm delete third party - if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { - $formconfirm = $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', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200', '', '', 1, null, false, array($object->id)) - ) - ); - - $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - - // Call Hook tabContentViewThirdparty - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentViewThirdparty', $parameters, $object, $action); - if (empty($reshook)) { - print '
'; - print '
'; - - print '
'; - print ''; - - // Type Prospect/Customer/Supplier - print ''; - - // Prefix - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''; - print ''; - } - - // Customer code - if ($object->client) { - print ''; - print ''; - print ''; - } - - // Supplier code - if (((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) && $object->fournisseur) { - print ''; - print ''; - } - - // Barcode - if (isModEnabled('barcode')) { - print ''; - 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 ''; - - - // This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier. - // We don't need them into customer profile. - // Except for spain and localtax where localtax depends on buyer and not seller - - if ($object->fournisseur) { - // VAT is used - print ''; - print ''; - - if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) { - // VAT reverse charge by default - print ''; - print ''; - } - } - - // Local Taxes - if ($object->fournisseur || $mysoc->country_code == 'ES') { - 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 ''; - } - } - } - - // Sale tax code (VAT code) - print ''; - print ''; - - // Warehouse - if (isModEnabled('stock') && getDolGlobalString('SOCIETE_ASK_FOR_WAREHOUSE')) { - $langs->load('stocks'); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - print ''; - print ''; - print ''; - } - - print '
'.$langs->trans('NatureOfThirdParty').''; - print $object->getTypeUrl(1); - print '
'.$langs->trans('Prefix').''.dol_escape_htmltag($object->prefix_comm).'
'; - print $langs->trans('CustomerCode'); - print ''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } - print '
'; - print $langs->trans('SupplierCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print '
'; - print $langs->trans('Gencod').''.showValueWithClipboardCPButton(dol_escape_htmltag($object->barcode)); - print '
'.$idprof.''; - $key = 'idprof'.$i; - print dol_print_profids($object->$key, 'ProfId'.$i, $object->country_code, 1); - if ($object->$key) { - if ($object->id_prof_check($i, $object) > 0) { - if (!empty($object->id_prof_url($i, $object))) { - print '   '.$object->id_prof_url($i, $object); - } - } else { - print ' ('.$langs->trans("ErrorWrongValue").')'; - } - } - print '
'; - print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling')); - print ''; - print yn($object->tva_assuj); - print '
'; - print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc')); - print ''; - print 'vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>'; - 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("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; - $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); - print ''.$object->localtax1_value.'
'.$langs->transcountry("Localtax2", $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("Localtax1", $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("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; - $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); - print ''.$object->localtax2_value.'
'.$langs->trans('VATIntra').''; - if ($object->tva_intra) { - $s = ''; - $s .= dol_print_profids($object->tva_intra, 'VAT', $object->country_code, 1); - $s .= ''; - - if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) { - $s .= '   '; - - if ($conf->use_javascript_ajax) { - $widthpopup = 600; - if (!empty($conf->dol_use_jmobile)) { - $widthpopup = 350; - } - $heightpopup = 400; - print "\n"; - print ''; - print "\n"; - $s .= ''.$langs->trans("VATIntraCheck").''; - $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1); - } else { - $s .= 'country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').''; - } - } - print $s; - } else { - print ' '; - } - print '
'; - print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $user->hasRight('societe', 'creer')); - print ''; - if ($action == 'editwarehouse') { - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'fk_warehouse', 1); - } else { - if ($object->fk_warehouse > 0) { - print img_picto('', 'stock', 'class="paddingrightonly"'); - } - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'none'); - } - print '
'; - print '
'; - - print '
'; - - print '
'; - print ''; - - // Tags / categories - if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { - // Customer - if ($object->prospect || $object->client || getDolGlobalString('THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT')) { - print ''; - print '"; - } - - // Supplier - if (((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) && $object->fournisseur) { - print ''; - print '"; - } - } - - - // Third-Party Type - print ''; - - // Workforce/Staff - if (!getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) { - print ''; - } - - // Legal - print ''; - - // Capital - print ''; - - // Unsubscribe opt-out - if (isModEnabled('mailing')) { - $result = $object->getNoEmail(); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - print ''; + print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - } - - // Multicurrency - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - - if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) { - // Accountancy sell code - print ''; - - // Accountancy buy code - print ''; - } - @@ -3038,14 +2199,236 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - // Parent company - if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY')) { - print ''; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + // Webservices url/key + if (!empty($conf->syncsupplierwebservices->enabled)) { + print ''; + print ''; + print ''; + print ''; + } + + // Logo + print ''; + print ''; + print ''; + print ''; + + // Assign sale representative + print ''; + print ''; + print ''; + + print '
'.$langs->trans("CustomersCategoriesShort").''; - print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1); - print "
'.$langs->trans("SuppliersCategoriesShort").''; - print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); - print "
'; - print ''; - if ($action != 'editthirdpartytype' && $user->hasRight('societe', 'creer')) { - print ''; - } - print '
'.$langs->trans('ThirdPartyType').'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - $html_name = ($action == 'editthirdpartytype') ? 'typent_id' : 'none'; - $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->typent_id, $html_name, ''); - print '
'.$langs->trans("Workforce").''.$object->effectif.'
'.$langs->trans('JuridicalStatus').''.$object->forme_juridique.'
'.$langs->trans('Capital').''; - if ($object->capital) { - if (isModEnabled("multicurrency") && !empty($object->multicurrency_code)) { - print price($object->capital, '', $langs, 0, -1, -1, $object->multicurrency_code); - } else { - print price($object->capital, '', $langs, 0, -1, -1, $conf->currency); - } - } else { - print ' '; - } - print '
'.$langs->trans("No_Email").''; - if ($object->email) { - print yn($object->no_email); - } else { - $langs->load("mails"); - print ''.$langs->trans("EMailNotDefined").''; - } - - $langs->load("mails"); - print '   '.$object->getNbOfEMailings().''; - + print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); @@ -2963,73 +2196,0 @@ - // Default language - if (getDolGlobalInt('MAIN_MULTILANGS')) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - 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 picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"'); - print $labellang; - print '
'; - print ''; - if ($action != 'editincoterm' && $user->hasRight('societe', 'creer')) { - print ''; - } - print '
'.$langs->trans('IncotermLabel').''.img_edit('', 1).'
'; - print '
'; - if ($action != 'editincoterm') { - print $form->textwithpicto($object->display_incoterms(), $object->label_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 '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code, 1) : ''; - print '
'; - print $langs->trans("ProductAccountancySellCode"); - print ''; - if (isModEnabled('accounting')) { - if (!empty($object->accountancy_code_sell)) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $object->accountancy_code_sell, 1); - - print $accountingaccount->getNomUrl(0, 1, 1, '', 1); - } - } else { - print $object->accountancy_code_sell; - } - print '
'; - print $langs->trans("ProductAccountancyBuyCode"); - print ''; - if (isModEnabled('accounting')) { - if (!empty($object->accountancy_code_buy)) { - $accountingaccount2 = new AccountingAccount($db); - $accountingaccount2->fetch('', $object->accountancy_code_buy, 1); - - print $accountingaccount2->getNomUrl(0, 1, 1, '', 1); - } - } else { - print $object->accountancy_code_buy; - } - print '
'; - print ''; - if ($action != 'editparentcompany' && $user->hasRight('societe', 'creer')) { - print ''; - } - print '
'.$langs->trans('ParentCompany').'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none'; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, null, 0, array($object->id)); - print '
'.$form->editfieldkey('WebServiceURL', 'webservices_url', '', $object, 0).''.$form->editfieldkey('WebServiceKey', 'webservices_key', '', $object, 0).'
'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; + 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 '
'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); + $arrayselected = GETPOST('commercial', 'array'); + if (empty($arrayselected)) $arrayselected = $object->getSalesRepresentatives($user, 1); + print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); + print '
'; + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print ''; + } + } + else + { + /* + * View + */ + + if (!empty($object->id)) $res = $object->fetch_optionals(); + //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, 250); + } + + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + + print '
'; + print '
'; + + print '
'; + print ''; + + // Prospect/Customer + print ''; + + // Supplier + if (!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) + { + print ''; + } + + // Prefix + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + print ''; + } + + // Customer code + if ($object->client) + { + print ''; + print ''; + } + + // Supplier code + if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) + { + print ''; + print ''; + } + + // Barcode + if (!empty($conf->barcode->enabled)) + { + print ''; + 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 ''; + + + // This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier. + // We don't need them into customer profile. + // Except for spain and localtax where localtax depends on buyer and not seller + + if ($object->fournisseur) + { + // VAT is used + print ''; + print ''; + } + + // Local Taxes + if ($object->fournisseur || $mysoc->country_code == 'ES') + { + 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 ''; + } @@ -3053,8 +2436,106 @@ - - // Sales representative - include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; - - // Module Adherent - if (isModEnabled('adherent')) { - $langs->load("members"); - 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 ''; + } + } + } + + // Sale tax code (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 $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling')); + 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("Localtax1", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + $formcompany->select_localtax(1, $object->localtax1_value, "lt1"); + print ''.$object->localtax1_value.'
'.$langs->transcountry("Localtax2", $mysoc->country_code).'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + print ''.$object->localtax2_value.'
'.$langs->trans("LinkedToDolibarrMember").'
'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).''; + print yn($object->localtax1_assuj); + print '
'.$langs->transcountry("Localtax1", $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("Localtax2", $mysoc->country_code).' id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + $formcompany->select_localtax(2, $object->localtax2_value, "lt2"); + print ''.$object->localtax2_value.'
'.$langs->trans('VATIntra').''; + if ($object->tva_intra) + { + $s = ''; + $s .= $object->tva_intra; + $s .= ''; + + if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) + { + $s .= '   '; + + if ($conf->use_javascript_ajax) + { + $widthpopup = 600; + if (!empty($conf->dol_use_jmobile)) $widthpopup = 350; + $heightpopup = 400; + print "\n"; + print ''; + print "\n"; + $s .= ''.$langs->trans("VATIntraCheck").''; + $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("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 || (!$object->fournisseur && !empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { + print ''; @@ -3062,9 +2543,2 @@ - $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 "\n"; + print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1); + print ""; @@ -3073,12 +2547,6 @@ - // Link user (you must create a contact to get a user) - /* - print ''; + print '"; @@ -3085,0 +2554,54 @@ + } + + // 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 ''; - print ''; - } - - print '
'.$langs->trans("CustomersCategoriesShort").'
'.$langs->trans("DolibarrLogin").''; - if ($object->user_id) { - $dolibarr_user = new User($db); - $result = $dolibarr_user->fetch($object->user_id); - print $dolibarr_user->getLoginUrl(-1); - } else { - //print ''.$langs->trans("NoDolibarrAccess").''; - if (!$object->user_id && $user->hasRight('user', 'user', 'creer')) { - print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").''; - } + // Supplier + if ($object->fournisseur) { + print '
'.$langs->trans("SuppliersCategoriesShort").''; + print $form->showCategories($object->id, Categorie::TYPE_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->label_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 '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code, 1) : ''; @@ -3087,13 +2608,0 @@ - */ - - // Webservices url/key - if (!empty($conf->syncsupplierwebservices->enabled)) { - print '
'.$langs->trans("WebServiceURL").''.dol_print_url($object->webservices_url).''.$langs->trans('WebServiceKey').''.$object->webservices_key.'
'; - print '
'; - - print '
'; - print '
'; @@ -3102,8 +2611,71 @@ - print dol_get_fiche_end(); - - - /* - * Actions - */ - if ($action != 'presend') { - print '
'."\n"; + // 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)) + { + 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 ''; + print ''; + } + + // Sales representative + include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; + + // Module Adherent + if (!empty($conf->adherent->enabled)) + { + $langs->load("members"); + print ''.$langs->trans("LinkedToDolibarrMember").''; + print ''; + $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 ''; + print "\n"; + } + + // Webservices url/key + if (!empty($conf->syncsupplierwebservices->enabled)) { + print ''.$langs->trans("WebServiceURL").''.dol_print_url($object->webservices_url).''; + print ''.$langs->trans('WebServiceKey').''.$object->webservices_key.''; + } + + print ''; + print '
'; + + print '
'; + print '
'; + + dol_fiche_end(); + + + /* + * Actions + */ + if ($action != 'presend') + { + print '
'."\n"; @@ -3113 +2685,2 @@ - if (empty($reshook)) { + if (empty($reshook)) + { @@ -3116,2 +2689,4 @@ - foreach ($TContact as &$contact) { - if (!empty($contact->email)) { + foreach ($TContact as &$contact) + { + if (!empty($contact->email)) + { @@ -3124,6 +2699,10 @@ - $langs->load("mails"); - $title = ''; - if (empty($object->email) && !$at_least_one_email_contact) { - $title = $langs->trans('NoEMail'); - } - print dolGetButtonAction($title, $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', 'btn-send-mail', !empty($object->email) || $at_least_one_email_contact); + if (!empty($object->email) || $at_least_one_email_contact) + { + $langs->load("mails"); + print ''.$langs->trans('SendMail').''; + } + else + { + $langs->load("mails"); + print ''.$langs->trans('SendMail').''; + } @@ -3132,3 +2711,7 @@ - print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); - - if (isModEnabled('adherent')) { + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Modify").''."\n"; + } + + if (!empty($conf->adherent->enabled)) + { @@ -3137,16 +2720,22 @@ - if ($result == 0 && ($object->client == 1 || $object->client == 3) && getDolGlobalString('MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS')) { - print ''.$langs->trans("NewMember").''."\n"; - } - } - - print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete); - - if ($user->hasRight('societe', 'supprimer')) { - $deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken(); - $buttonId = 'action-delete-no-ajax'; - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile - $deleteUrl = ''; - $buttonId = 'action-delete'; - } - print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $deleteUrl, $buttonId, $permissiontodelete); - } + if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) + { + print ''.$langs->trans("NewMember").''; + } + } + + if ($user->rights->societe->supprimer) + { + print ''.$langs->trans('Merge').''; + } + + 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 ''.$langs->trans('Delete').''."\n"; + } + } @@ -3155,4 +2744,4 @@ - print '
'."\n"; - } - - //Select mail models is same action as presend + print ''."\n"; + } + + //Select mail models is same action as presend @@ -3163 +2752,2 @@ - if ($action != 'presend') { + if ($action != 'presend') + { @@ -3166 +2756,2 @@ - if (!getDolGlobalString('SOCIETE_DISABLE_BUILDDOC')) { + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) + { @@ -3169,10 +2760,10 @@ - /* - * Generated documents - */ - $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed = $user->hasRight('societe', 'lire'); - $delallowed = $user->hasRight('societe', 'creer'); - - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); - } + /* + * 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; + + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + } @@ -3181,2 +2772,2 @@ - if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY') && !getDolGlobalString('SOCIETE_DISABLE_SHOW_SUBSIDIARIES')) { - print '
'; + if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) + { @@ -3186 +2777 @@ - print '
'; + print '
'; @@ -3190,4 +2781 @@ - $morehtmlcenter = '
'; - $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id); - $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id); - $morehtmlcenter .= '
'; + $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id); @@ -3198,5 +2786,6 @@ - $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty - - print '
'; - - if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD')) { + $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty + + print ''; + + if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) + { @@ -3204 +2793,2 @@ - if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) { + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { @@ -3205,0 +2796,6 @@ + } + + // Addresses list + if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + $result = show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); @@ -3213 +2809 @@ - $diroutput = $conf->societe->multidir_output[$object->entity]; + $diroutput = $conf->societe->dir_output; @@ -3217 +2813 @@ - } + } @@ -3219 +2814,0 @@ - @@ -3224,44 +2818,0 @@ - -?> - - --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_consumption.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_consumption.php @@ -7 +6,0 @@ - * Copyright (C) 2021-2022 Frédéric France @@ -29 +27,0 @@ -// Load Dolibarr environment @@ -36,6 +34 @@ - -// Load translation files required by the page -$langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); - - -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; @@ -45,3 +38 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -50,3 +41 @@ -if ($socid > 0) { - $object->fetch($socid); -} +if ($socid > 0) $object->fetch($socid); @@ -55,9 +44,5 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -$optioncss = GETPOST('optioncss', 'alpha'); - -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -67,6 +52,2 @@ -if (!$sortorder) { - $sortorder = 'DESC'; -} -if (!$sortfield) { - $sortfield = 'dateprint'; -} +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'dateprint'; @@ -81,7 +62,7 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $sref = ''; - $sprod_fulldescr = ''; - $year = ''; - $month = ''; -} - +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +{ + $sref = ''; + $sprod_fulldescr = ''; + $year = ''; + $month = ''; +} @@ -89,3 +70,5 @@ -$thirdTypeSelect = GETPOST("third_select_id", 'aZ09'); -$type_element = GETPOST('type_element') ? GETPOST('type_element') : ''; - +$thirdTypeSelect = GETPOST("third_select_id"); +$type_element = GETPOST('type_element') ?GETPOST('type_element') : ''; + +// Load translation files required by the page +$langs->loadLangs(array("companies", "bills", "orders", "suppliers", "propal", "interventions", "contracts", "products")); @@ -94 +77 @@ -$hookmanager->initHooks(array('consumptionthirdparty', 'globalcard')); +$hookmanager->initHooks(array('consumptionthirdparty')); @@ -103,3 +86 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -118,3 +99 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name." - ".$title; -} +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; @@ -124 +103,2 @@ -if (empty($socid)) { +if (empty($socid)) +{ @@ -130 +110 @@ -print dol_get_fiche_head($head, 'consumption', $langs->trans("ThirdParty"), -1, 'company'); +dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"), -1, 'company'); @@ -141,6 +121,2 @@ -// Type Prospect/Customer/Supplier -print ''.$langs->trans('NatureOfThirdParty').''; -print $object->getTypeUrl(1); -print ''; - -if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field +if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +{ @@ -150,4 +126,4 @@ -//if (isModEnabled('agenda') && $user->hasRight('agenda', 'myactions', 'read')) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); -$elementTypeArray = array(); - -if ($object->client) { +//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); + +if ($object->client) +{ @@ -156,5 +132,2 @@ - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -162 +135 @@ - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; @@ -164,3 +137 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -171,19 +142,10 @@ - if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { - $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); - } - if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { - $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); - } - if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { - $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); - } - if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { - $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); - } -} - -if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire')) { - $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); -} - -if ($object->fournisseur) { + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); +} + +if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); + +if ($object->fournisseur) +{ @@ -193,5 +155,2 @@ - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -199 +158 @@ - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".((int) $socid); + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; @@ -201,3 +160 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -208,9 +165,3 @@ - if ((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'facture', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) { - $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); - } - if ((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'commande', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire'))) { - $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); - } - if (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire')) { - $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals'); - } + if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); + if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); + if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal'] = $langs->transnoentitiesnoconv('SupplierProposals'); @@ -222 +173 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -230 +180,0 @@ -$documentstaticline = ''; @@ -241 +191,2 @@ -if ($type_element == 'fichinter') { // Customer : show products from invoices +if ($type_element == 'fichinter') +{ // Customer : show products from invoices @@ -244,2 +195 @@ - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, NULL as paid, '; - $sql_select .= 'NULL as fk_product, NULL as info_bits, NULL as date_start, NULL as date_end, NULL as prod_qty, NULL as total_ht, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, f.fk_statut as status, '; @@ -247 +197 @@ - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -252 +202,2 @@ -if ($type_element == 'invoice') { // Customer : show products from invoices +if ($type_element == 'invoice') +{ // Customer : show products from invoices @@ -255 +206 @@ - $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, d.fk_remise_except, '; + $sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, f.type as doc_type, f.datef as dateprint, f.fk_statut as status, f.paye as paid, '; @@ -257 +208 @@ - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -264 +215,2 @@ -if ($type_element == 'propal') { +if ($type_element == 'propal') +{ @@ -267 +219 @@ - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, NULL as paid,'; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, c.fk_statut as status, '; @@ -269 +221 @@ - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -272 +224 @@ - $dateprint = 'c.datep'; + $datePrint = 'c.datep'; @@ -276 +228,2 @@ -if ($type_element == 'order') { +if ($type_element == 'order') +{ @@ -278 +230,0 @@ - $langs->load('sendings'); // delivery planned date @@ -280 +232 @@ - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, NULL as paid, c.date_livraison as delivery_planned_date,'; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, c.fk_statut as status, '; @@ -282 +234 @@ - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -289 +241,2 @@ -if ($type_element == 'supplier_invoice') { // Supplier : Show products from invoices. +if ($type_element == 'supplier_invoice') +{ // Supplier : Show products from invoices. @@ -294 +247 @@ - $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -301,13 +254,15 @@ -if ($type_element == 'supplier_proposal') { - require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - $documentstatic = new SupplierProposal($db); - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, NULL as paid, '; - $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); - $where .= " AND d.fk_supplier_proposal = c.rowid"; - $where .= " AND c.entity = ".$conf->entity; - $dateprint = 'c.date_valid'; - $doc_number = 'c.ref'; - $thirdTypeSelect = 'supplier'; -} -if ($type_element == 'supplier_order') { // Supplier : Show products from orders. +if ($type_element == 'supplier_proposal') +{ + require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; + $documentstatic = new SupplierProposal($db); + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; + $tables_from = MAIN_DB_PREFIX."supplier_proposal as c,".MAIN_DB_PREFIX."supplier_proposaldet as d"; + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; + $where .= " AND d.fk_supplier_proposal = c.rowid"; + $where .= " AND c.entity = ".$conf->entity; + $dateprint = 'c.date_valid'; + $doc_number = 'c.ref'; + $thirdTypeSelect = 'supplier'; +} +if ($type_element == 'supplier_order') +{ // Supplier : Show products from orders. @@ -315 +269,0 @@ - $langs->load('sendings'); // delivery planned date @@ -317 +271 @@ - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, NULL as paid, c.date_livraison as delivery_planned_date, '; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, c.fk_statut as status, '; @@ -319 +273 @@ - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -326 +280,2 @@ -if ($type_element == 'contract') { // Order +if ($type_element == 'contract') +{ // Order @@ -330 +285 @@ - $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, NULL as paid,'; + $sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_contrat as dateprint, d.statut as status, '; @@ -332 +287 @@ - $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".((int) $socid); + $where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; @@ -343 +298,2 @@ -if (!empty($sql_select)) { +if (!empty($sql_select)) +{ @@ -346,12 +302,4 @@ - if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') { - $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; - } - if ($type_element == 'supplier_proposal') { - $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; - } - if ($type_element == 'contract') { - $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; - } - if ($type_element != 'fichinter') { - $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity, '; - } + if ($type_element != 'fichinter' && $type_element != 'contract' && $type_element != 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; + if ($type_element == 'supplier_proposal') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; + if ($type_element == 'contract') $sql .= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_ouverture as date_start, d.date_cloture as date_end, d.qty, d.qty as prod_qty, d.total_ht as total_ht, '; + if ($type_element != 'fichinter') $sql .= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type, p.entity as pentity,'; @@ -359,3 +307 @@ - if ($type_element != 'fichinter') { - $sql .= ", p.ref as prod_ref, p.label as product_label"; - } + if ($type_element != 'fichinter') $sql .= ", p.ref as prod_ref, p.label as product_label"; @@ -363,3 +309 @@ - if ($type_element != 'fichinter') { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; - } + if ($type_element != 'fichinter') $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; @@ -368,13 +312,7 @@ - if ($sref) { - $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; - } - if ($sprod_fulldescr) { - // We test both case description is correctly saved of was save after dol_escape_htmltag(). - $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%' OR d.description LIKE '%".$db->escape(dol_escape_htmltag($sprod_fulldescr))."%'"; - if (GETPOST('type_element') != 'fichinter') { - $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; - } - if (GETPOST('type_element') != 'fichinter') { - $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; - } - $sql .= ")"; + if ($sref) $sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; + if ($sprod_fulldescr) + { + $sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; + if (GETPOST('type_element') != 'fichinter') $sql .= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql .= ")"; @@ -393,3 +331,4 @@ -if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) { - $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); - $disabled = 1; +if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) +{ + $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); + $disabled = 1; @@ -400 +339,9 @@ -$button = ''; +$button = ''; + +$param = ''; +$param .= "&sref=".urlencode($sref); +$param .= "&month=".urlencode($month); +$param .= "&year=".urlencode($year); +$param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); +$param .= "&socid=".urlencode($socid); +$param .= "&type_element=".urlencode($type_element); @@ -403,3 +350,3 @@ -$param = ''; - -if ($sql_select) { + +if ($sql_select) +{ @@ -407,3 +354 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -414,69 +359,47 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($sprod_fulldescr) { - $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); - } - if ($sref) { - $param .= "&sref=".urlencode($sref); - } - if ($month) { - $param .= "&month=".urlencode($month); - } - if ($year) { - $param .= "&year=".urlencode($year); - } - if ($optioncss) { - $param .= '&optioncss='.urlencode($optioncss); - } - - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); - - print '
'; - print ''."\n"; - - // Filters - print ''; - print ''; - print ''; - // delivery planned date - if ($type_element == 'order' || $type_element == 'supplier_order') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, '', $sortfield, $sortorder, 'center '); - // delivery planned date - if ($type_element == 'order' || $type_element == 'supplier_order') { - print_liste_field_titre('DateDeliveryPlanned', $_SERVER['PHP_SELF'], 'delivery_planned_date', '', $param, '', $sortfield, $sortorder, 'center '); - } - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sprod_fulldescr) $param .= "&sprod_fulldescr=".urlencode($sprod_fulldescr); + if ($sref) $param .= "&sref=".urlencode($sref); + if ($month) $param .= "&month=".urlencode($month); + if ($year) $param .= "&year=".urlencode($year); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); + + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, '', 0, '', '', $limit); + + print '
'; + print '
'; - print ''; - print ''; // date - print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); - print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 1, 0, 0, '', 'valignmiddle maxwidth75imp marginleftonly'); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'."\n"; + + // Filters + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_statut', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('TotalHT', $_SERVER['PHP_SELF'], 'total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre('UnitPrice', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; @@ -486 +409,2 @@ - while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) { + while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) + { @@ -495,5 +419,2 @@ - $documentstatic->alreadypaid = $objp->paid; - - if (is_object($documentstaticline)) { - $documentstaticline->statut = $objp->status; - } + + if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status; @@ -506,4 +426,0 @@ - // delivery planned date - if ($type_element == 'order' || $type_element == 'supplier_order') { - print ''; - } @@ -513,8 +430,7 @@ - if ($type_element == 'contract') { - print $documentstaticline->getLibStatut(5); - } elseif ($type_element == 'invoice') { - print $documentstatic->getLibStatut(5, $objp->paid); - } elseif ($type_element == 'supplier_invoice') { - print $documentstatic->getLibStatut(5, $objp->paid); - } else { - print $documentstatic->getLibStatut(5); + if ($type_element == 'contract') + { + print $documentstaticline->getLibStatut(2); + } + else + { + print $documentstatic->getLibStatut(2); @@ -524,2 +440 @@ - // Label - print ''; + if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) $objp->prod_qty = -($objp->prod_qty); + print ''; @@ -675,5 +591,2 @@ - print ''; - if (empty($total_ht)) { - $total_ht = 0; - } - $total_ht += (float) $objp->total_ht; + print ''; + $total_ht += $objp->total_ht; @@ -690,4 +602,0 @@ - // delivery planned date - if ($type_element == 'order' || $type_element == 'supplier_order') { - print ''; - } @@ -696 +605 @@ - print ''; + print ''; @@ -704,14 +613,16 @@ -} elseif (empty($type_element) || $type_element == -1) { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', ''); - - print '
'; + print ''; + print ''; // date + print $formother->select_month($month ? $month : -1, 'month', 1, 0, 'valignmiddle'); + $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'.dol_print_date($db->jdate($objp->delivery_planned_date), 'day').''; + print ''; @@ -528,3 +443 @@ - $text = ''; - $description = ''; - $type = 0; + $text = ''; $description = ''; $type = 0; @@ -533 +446,2 @@ - if ($objp->fk_product > 0) { + if ($objp->fk_product > 0) + { @@ -544 +458,2 @@ - if ($objp->fk_product > 0) { + if ($objp->fk_product > 0) + { @@ -546 +461,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { @@ -552,7 +468,4 @@ - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (empty($newlang)) { - $newlang = $object->default_lang; - } - if (!empty($newlang)) { + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (empty($newlang)) $newlang = $object->default_lang; + if (!empty($newlang)) + { @@ -564 +477,3 @@ - } else { + } + else + { @@ -569 +484 @@ - $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($objp->description)); + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description)); @@ -577,7 +492,3 @@ - if ($objp->description == '(DEPOSIT)') { - $txt = $langs->trans("Deposit"); - } elseif ($objp->description == '(EXCESS RECEIVED)') { - $txt = $langs->trans("ExcessReceived"); - } elseif ($objp->description == '(EXCESS PAID)') { - $txt = $langs->trans("ExcessPaid"); - } + if ($objp->description == '(DEPOSIT)') $txt = $langs->trans("Deposit"); + elseif ($objp->description == '(EXCESS RECEIVED)') $txt = $langs->trans("ExcessReceived"); + elseif ($objp->description == '(EXCESS PAID)') $txt = $langs->trans("ExcessPaid"); @@ -589,3 +500,4 @@ - if ($objp->description) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) { + if ($objp->description) + { + if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) + { @@ -594,3 +506,4 @@ - echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); - } - if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); + } + if ($objp->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) + { @@ -599,2 +512,4 @@ - echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); - } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); + } + elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) + { @@ -603,2 +518,4 @@ - echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); - } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); + } + elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + { @@ -607 +524 @@ - echo($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); + echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); @@ -609,5 +526,5 @@ - if (getDolGlobalString('INVOICE_ADD_DEPOSIT_DATE')) { - echo ' ('.dol_print_date($discount->datec).')'; - } - } else { - echo($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + } + else + { + echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); @@ -616 +533,3 @@ - } else { + } + else + { @@ -624 +543,2 @@ - if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) + { @@ -628,6 +548,4 @@ - if (!empty($objp->label) || !empty($objp->description)) { - if ($type == 1) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } + if (!empty($objp->label) || !empty($objp->description)) + { + if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); @@ -661 +579 @@ - if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) @@ -663 +581 @@ - $prodreftxt .= (!empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + $prodreftxt .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; @@ -669,4 +587,2 @@ - if ($type_element == 'invoice' && $objp->doc_type == Facture::TYPE_CREDIT_NOTE) { - $objp->prod_qty = -($objp->prod_qty); - } - print '
'.$objp->prod_qty.''.$objp->prod_qty.''.price($objp->total_ht).''.price($objp->total_ht).''.price(price2num($total_ht / (empty($total_qty) ? 1 : $total_qty), 'MU')).''.price($total_ht / (empty($total_qty) ? 1 : $total_qty)).'
'."\n"; - // Titles with sort buttons - print ''; - print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); - print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); - print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); - print "\n"; - - print ''; +} +elseif (empty($type_element) || $type_element == -1) +{ + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + + print '
'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
'."\n"; + // Titles with sort buttons + print ''; + print_liste_field_titre('Ref', $_SERVER['PHP_SELF'], 'doc_number', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Date', $_SERVER['PHP_SELF'], 'dateprint', '', $param, 'width="150"', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Status', $_SERVER['PHP_SELF'], 'fk_status', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre('Product', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'left '); + print_liste_field_titre('Quantity', $_SERVER['PHP_SELF'], 'prod_qty', '', $param, '', $sortfield, $sortorder, 'right '); + print "\n"; + + print ''; @@ -720,6 +631,7 @@ -} else { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - - print '
'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
'."\n"; - - print ''; +} +else { + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + + print '
'.$langs->trans("FeatureNotYetAvailable").'
'."\n"; + + print ''; --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_contact.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_contact.php @@ -34 +33,0 @@ -// Load Dolibarr environment @@ -46,3 +45 @@ -if (isModEnabled('adherent')) { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -} +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -50 +46,0 @@ -// Load translation files required by the page @@ -52,10 +48,3 @@ - -if (isModEnabled('categorie')) { - $langs->load("categories"); -} -if (isModEnabled('incoterm')) { - $langs->load("incoterm"); -} -if (isModEnabled('notification')) { - $langs->load("mails"); -} +if (!empty($conf->categorie->enabled)) $langs->load("categories"); +if (!empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (!empty($conf->notification->enabled)) $langs->load("mails"); @@ -64,0 +54,7 @@ +$action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); +$cancel = GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); +$confirm = GETPOST('confirm'); +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; +if (empty($socid) && $action == 'view') $action = 'create'; @@ -66,16 +61,0 @@ -// Get parameters -$action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); -$cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); -$confirm = GETPOST('confirm'); -$socid = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); - -if ($user->socid) { - $socid = $user->socid; -} - -if (empty($socid) && $action == 'view') { - $action = 'create'; -} - -// Initialize objects @@ -91 +71,2 @@ -if ($object->fetch($socid) <= 0 && $action == 'view') { +if ($action == 'view' && $object->fetch($socid) <= 0) +{ @@ -97,0 +79 @@ +$object->getCanvas($socid); @@ -100,4 +82,5 @@ -if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('thirdparty', 'card', $canvas); +if (!empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('thirdparty', 'card', $canvas); @@ -107,4 +90,4 @@ -$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); -if (!$user->hasRight('societe', 'contact', 'lire')) { - accessforbidden(); -} +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); +if (empty($user->rights->societe->contact->lire)) accessforbidden(); + + @@ -119,3 +102 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -123,8 +104,11 @@ -if (empty($reshook)) { - if ($cancel) { - $action = ''; - if (!empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - } +if (empty($reshook)) +{ + if ($cancel) + { + $action = ''; + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } @@ -132,2 +116,2 @@ - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -146,5 +130,4 @@ -if ($socid > 0 && empty($object->id)) { - $result = $object->fetch($socid); - if ($result <= 0) { - dol_print_error('', $object->error); - } +if ($socid > 0 && empty($object->id)) +{ + $result = $object->fetch($socid); + if ($result <= 0) dol_print_error('', $object->error); @@ -154,3 +137 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name." - ".$langs->trans('ContactsAddresses'); -} +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card'); @@ -163,3 +144 @@ -if (!empty($object->id)) { - $res = $object->fetch_optionals(); -} +if (!empty($object->id)) $res = $object->fetch_optionals(); @@ -171 +150 @@ -print dol_get_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); +dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); @@ -177 +156 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -181 +160,2 @@ -if ($action != 'presend') { +if ($action != 'presend') +{ @@ -183,2 +163,3 @@ - if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) { - $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1); + if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) + { + $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id); --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_document.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_document.php @@ -29 +28,0 @@ -// Load Dolibarr environment @@ -36,2 +34,0 @@ - -// Load translation files required by the page @@ -39,0 +37,12 @@ +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$ref = GETPOST('ref', 'alpha'); + +// Security check +if ($user->socid > 0) +{ + unset($action); + $socid = $user->socid; +} +$result = restrictedArea($user, 'societe', $id, '&societe'); @@ -42,4 +51,8 @@ -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -$ref = GETPOST('ref', 'alpha'); +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; @@ -47,4 +60,2 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; } +if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; } @@ -52,3 +63,2 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "position_name"; @@ -56,19 +65,0 @@ -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) { - $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; -} -if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) { - $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; -} - -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "position_name"; -} - -// Initialize objects @@ -76 +67,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -86,12 +77,0 @@ -$permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - -// Security check -if ($user->socid > 0) { - unset($action); - $socid = $user->socid; -} -$result = restrictedArea($user, 'societe', $object->id, '&societe'); - -if (empty($object->id)) { - accessforbidden(); -} @@ -104 +84 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -114,3 +94 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name.' - '.$langs->trans("Files"); -} +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files"); @@ -120,5 +98,7 @@ -// Show tabs -if (isModEnabled('notification')) { - $langs->load("mails"); -} -$head = societe_prepare_head($object); +if ($object->id) +{ + /* + * Show tabs + */ + if (!empty($conf->notification->enabled)) $langs->load("mails"); + $head = societe_prepare_head($object); @@ -126 +106,3 @@ -print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); + $form = new Form($db); + + dol_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); @@ -129,5 +111,58 @@ -// Build file list -$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); -$totalsize = 0; -foreach ($filearray as $key => $file) { - $totalsize += $file['size']; + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) + { + $totalsize += $file['size']; + } + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print '
'.$langs->trans("FeatureNotYetAvailable").'
'; + + // Prefix + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } + + if ($object->client) + { + print ''; + } + + if ($object->fournisseur) + { + print ''; + } + + // Number of files + print ''; + + // Total size + print ''; + + 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 '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + + print '
'; + + dol_fiche_end(); + + $modulepart = 'societe'; + $permission = $user->rights->societe->creer; + $permtoedit = $user->rights->societe->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; @@ -135,18 +170,3 @@ - -$linkback = ''.$langs->trans("BackToList").''; - -dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - -print '
'; - -print '
'; -print ''; - -// Type Prospect/Customer/Supplier -print ''; - -// Prefix -if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''; +else +{ + accessforbidden('', 0, 0); @@ -154,40 +173,0 @@ - -if ($object->client) { - print ''; -} - -if ($object->fournisseur) { - print ''; -} - -// Number of files -print ''; - -// Total size -print ''; - -print '
'.$langs->trans('NatureOfThirdParty').''; -print $object->getTypeUrl(1); -print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; - print $langs->trans('CustomerCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } - print '
'; - print $langs->trans('SupplierCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; - -print '
'; - -print dol_get_fiche_end(); - -$modulepart = 'societe'; -$permissiontoadd = $user->hasRight('societe', 'creer'); -$permtoedit = $user->hasRight('societe', 'creer'); -$param = '&id='.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_index.php @@ -5 +5 @@ - * Copyright (C) 2014-2021 Charlene Benke + * Copyright (C) 2014 Charles-Fr Benke @@ -30 +29,0 @@ -// Load Dolibarr environment @@ -33,4 +32,6 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - - -// Load translation files required by the page + +$hookmanager = new HookManager($db); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('thirdpartiesindex')); + @@ -39,7 +39,0 @@ - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager = new HookManager($db); -$hookmanager->initHooks(array('thirdpartiesindex')); - - - @@ -47,3 +41 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -56,20 +47,0 @@ -if (!isset($form) || !is_object($form)) { - $form = new Form($db); -} - -// Load $resultboxes -$resultboxes = FormOther::getBoxesArea($user, "3"); - -if (GETPOST('addbox')) { - // Add box (when submit is done from a form when ajax disabled) - require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - $zone = GETPOST('areacode', 'int'); - $userid = GETPOST('userid', 'int'); - $boxorder = GETPOST('boxorder', 'aZ09'); - $boxorder .= GETPOST('boxcombo', 'aZ09'); - $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); - if ($result > 0) { - setEventMessages($langs->trans("BoxAdded"), null); - } -} - @@ -85,2 +57,7 @@ - -print load_fiche_titre($transAreaType, $resultboxes['selectboxlist'], 'companies'); +$linkback = ''; +print load_fiche_titre($transAreaType, $linkback, 'companies'); + + +//print ''; +//print ''; + // Name + print '\n"; + // Type + print ''; + // Last modified date + print '"; + print '"; + print "\n"; + $i++; + } + + $db->free($result); + + print "
'; +print '
'; @@ -103,3 +80 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -107,15 +82,3 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} -if (!$user->hasRight('fournisseur', 'lire')) { - $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible -} -// Add where from hooks -$parameters = array('socid' => $socid); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdparty_static); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - if ($socid > 0) { - $sql .= " AND s.rowid = ".((int) $socid); - } -} -$sql .= $hookmanager->resPrint; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible @@ -124,47 +87,27 @@ -if ($result) { - while ($objp = $db->fetch_object($result)) { - $found = 0; - if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS_STATS') && ($objp->client == 2 || $objp->client == 3)) { - $found = 1; - $third['prospect']++; - } - if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS_STATS') && ($objp->client == 1 || $objp->client == 3)) { - $found = 1; - $third['customer']++; - } - if (((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && !getDolGlobalString('SOCIETE_DISABLE_SUPPLIERS_STATS') && $objp->fournisseur) { - $found = 1; - $third['supplier']++; - } - if (isModEnabled('societe') && $objp->client == 0 && $objp->fournisseur == 0) { - $found = 1; - $third['other']++; - } - if ($found) { - $total++; - } - } -} else { - dol_print_error($db); -} - -$thirdpartygraph = '
'; -$thirdpartygraph .= ''."\n"; -$thirdpartygraph .= ''; -if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) { - $thirdpartygraph .= ''."\n"; +} +else +{ + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) + { + $statstring = ""; + $statstring .= ''; + $statstring .= ""; + } + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) + { + $statstring .= ""; + $statstring .= ''; + $statstring .= ""; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) + { + $statstring2 = ""; + $statstring2 .= ''; + $statstring2 .= ""; + } + print $statstring; + print $statstring2; +} +print ''; +print '
'.$langs->trans("Statistics").'
'; - $dataseries = array(); - if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS_STATS')) { - $dataseries[] = array($langs->transnoentitiesnoconv("Prospects"), round($third['prospect'])); - } - if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS_STATS')) { - $dataseries[] = array($langs->transnoentitiesnoconv("Customers"), round($third['customer'])); - } - if (((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && !getDolGlobalString('SOCIETE_DISABLE_SUPPLIERS_STATS')) { - $dataseries[] = array($langs->transnoentitiesnoconv("Suppliers"), round($third['supplier'])); - } - if (isModEnabled('societe')) { - $dataseries[] = array($langs->transnoentitiesnoconv("Others"), round($third['other'])); - } - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; - $dolgraph = new DolGraph(); +if ($result) +{ + while ($objp = $db->fetch_object($result)) + { + $found = 0; + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; } + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; } + if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; } + if ($found) $total++; + } +} +else dol_print_error($db); + +print '
'; +print ''."\n"; +print ''; +if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) +{ + print ''."\n"; -} else { - if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS') && !getDolGlobalString('SOCIETE_DISABLE_PROSPECTS_STATS')) { - $statstring = ""; - $statstring .= ''; - $statstring .= ""; - } - if (isModEnabled('societe') && $user->hasRight('societe', 'lire') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS') && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS_STATS')) { - $statstring .= ""; - $statstring .= ''; - $statstring .= ""; - } - $statstring2 = ''; - if (((isModEnabled('fournisseur') && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled('supplier_order') && $user->hasRight('supplier_order', 'lire')) || (isModEnabled('supplier_invoice') && $user->hasRight('supplier_invoice', 'lire'))) && !getDolGlobalString('SOCIETE_DISABLE_SUPPLIERS_STATS')) { - $statstring2 = ""; - $statstring2 .= ''; - $statstring2 .= ""; - } - $thirdpartygraph .= $statstring; - $thirdpartygraph .= $statstring2; -} -$thirdpartygraph .= ''; -$thirdpartygraph .= '
'.$langs->trans("Statistics").'
'; + $dataseries = array(); + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect'])); + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier'])); + if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other'])); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); @@ -177,30 +120,34 @@ - $thirdpartygraph .= $dolgraph->show(); - $thirdpartygraph .= '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$langs->trans("UniqueThirdParties").''; -$thirdpartygraph .= $total; -$thirdpartygraph .= '
'; -$thirdpartygraph .= '
'; - -$thirdpartycateggraph = ''; -if (isModEnabled('categorie') && getDolGlobalString('CATEGORY_GRAPHSTATS_ON_THIRDPARTIES')) { + print $dolgraph->show(); + print '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$langs->trans("UniqueThirdParties").''; +print $total; +print '
'; +print '
'; + +if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) +{ @@ -210,4 +157,6 @@ - $thirdpartycateggraph = '
'; - $thirdpartycateggraph .= ''; - $thirdpartycateggraph .= ''; - $thirdpartycateggraph .= ''; + print ''; + print '
'.$langs->trans("Categories").'
'; + print '
'; + + print '
'; + print ''; + print ''; + print ''; + print ''; @@ -265,9 +222,10 @@ - $thirdpartycateggraph .= ''; - $thirdpartycateggraph .= ''; - $thirdpartycateggraph .= '
'.$langs->trans("Categories").'
'; @@ -218,3 +167 @@ - if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { - $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; - } + if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; @@ -225 +172,2 @@ - if ($result) { + if ($result) + { @@ -228 +176,2 @@ - if (!empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) + { @@ -233 +182,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -235 +185,2 @@ - if ($i < $nbmax) { + if ($i < $nbmax) + { @@ -237 +188,3 @@ - } else { + } + else + { @@ -243 +196,2 @@ - if ($i > $nbmax) { + if ($i > $nbmax) + { @@ -254,3 +208,6 @@ - $thirdpartycateggraph .= $dolgraph->show(); - } else { - while ($i < $num) { + print $dolgraph->show(); + } + else + { + while ($i < $num) + { @@ -259 +216 @@ - $thirdpartycateggraph .= '
'.$obj->label.''.$obj->nb.'
'.$obj->label.''.$obj->nb.'
'.$langs->trans("Total").''; - $thirdpartycateggraph .= $total; - $thirdpartycateggraph .= '
'; - $thirdpartycateggraph .= '
'; -} else { - $thirdpartycateggraph = ''; -} + print '
'.$langs->trans("Total").''; + print $total; + print '
'; + print '
'; +} + +//print '
'; +print '
'; @@ -283,7 +241,2 @@ -if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= ", spe.accountancy_code_supplier as code_compta_fournisseur"; - $sql .= ", spe.accountancy_code_customer as code_compta"; -} else { - $sql .= ", s.code_compta_fournisseur"; - $sql .= ", s.code_compta"; -} +$sql .= ", s.code_compta_fournisseur"; +$sql .= ", s.code_compta"; @@ -294,6 +247 @@ -if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); -} -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -301,15 +249,3 @@ -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} -if (!$user->hasRight('fournisseur', 'lire')) { - $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; -} -// Add where from hooks -$parameters = array('socid' => $socid); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $thirdparty_static); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - if ($socid > 0) { - $sql .= " AND s.rowid = ".((int) $socid); - } -} -$sql .= $hookmanager->resPrint; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; @@ -320 +255,0 @@ -$lastmodified=""; @@ -322,31 +257,34 @@ -if ($result) { - $num = $db->num_rows($result); - - $i = 0; - - if ($num > 0) { - $transRecordedType = $langs->trans("LastModifiedThirdParties", $max); - - $lastmodified = "\n\n"; - $lastmodified .= '
'; - $lastmodified .= ''; - - $lastmodified .= ''; - $lastmodified .= ''; - $lastmodified .= ''; - $lastmodified .= ''."\n"; - - while ($i < $num) { - $objp = $db->fetch_object($result); - - $thirdparty_static->id = $objp->rowid; - $thirdparty_static->name = $objp->name; - $thirdparty_static->client = $objp->client; - $thirdparty_static->fournisseur = $objp->fournisseur; - $thirdparty_static->logo = $objp->logo; - $thirdparty_static->date_modification = $db->jdate($objp->date_modification); - $thirdparty_static->status = $objp->status; - $thirdparty_static->code_client = $objp->code_client; - $thirdparty_static->code_fournisseur = $objp->code_fournisseur; - $thirdparty_static->canvas = $objp->canvas; - $thirdparty_static->email = $objp->email; +if ($result) +{ + $num = $db->num_rows($result); + + $i = 0; + + if ($num > 0) + { + $transRecordedType = $langs->trans("LastModifiedThirdParties", $max); + + print "\n\n"; + print '
'; + print '
'.$transRecordedType.' '.$langs->trans("FullList").'
'; + + print ''; + print ''; + print ''; + print ''."\n"; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + + $thirdparty_static->id = $objp->rowid; + $thirdparty_static->name = $objp->name; + $thirdparty_static->client = $objp->client; + $thirdparty_static->fournisseur = $objp->fournisseur; + $thirdparty_static->logo = $objp->logo; + $thirdparty_static->date_modification = $db->jdate($objp->date_modification); + $thirdparty_static->status = $objp->status; + $thirdparty_static->code_client = $objp->code_client; + $thirdparty_static->code_fournisseur = $objp->code_fournisseur; + $thirdparty_static->canvas = $objp->canvas; + $thirdparty_static->email = $objp->email; @@ -354,60 +292,53 @@ - $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdparty_static->code_compta = $objp->code_compta; - - $lastmodified .= ''; - // Name - $lastmodified .= '\n"; - // Type - $lastmodified .= ''; - // Last modified date - $lastmodified .= '"; - $lastmodified .= '"; - $lastmodified .= "\n"; - $i++; - } - - $db->free($result); - - $lastmodified .= "
'.$transRecordedType.' '.$langs->trans("FullList").'
'; - $lastmodified .= $thirdparty_static->getNomUrl(1); - $lastmodified .= "'; - $lastmodified .= $thirdparty_static->getTypeUrl(); - $lastmodified .= 'date_modification, 'dayhour', 'tzuserrel')).'">'; - $lastmodified .= dol_print_date($thirdparty_static->date_modification, 'day', 'tzuserrel'); - $lastmodified .= "'; - $lastmodified .= $thirdparty_static->getLibStatut(3); - $lastmodified .= "
\n"; - $lastmodified .= '
'; - $lastmodified .= "\n"; - } -} else { - dol_print_error($db); -} - -//print '
'; - -// boxes -print '
'; -print '
'; - -$boxlist = '
'; - -$boxlist .= '
'; -$boxlist .= $thirdpartygraph; -$boxlist .= '
'; -$boxlist .= $thirdpartycateggraph; -$boxlist .= '
'; -$boxlist .= $resultboxes['boxlista']; -$boxlist .= '
'."\n"; - -$boxlist .= '
'; -$boxlist .= $lastmodified; -$boxlist .= '
'; -$boxlist .= $resultboxes['boxlistb']; -$boxlist .= '
'."\n"; - -$boxlist .= '
'; - -print $boxlist; - -print '
'; + $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdparty_static->code_compta = $objp->code_compta; + + print '
'; + print $thirdparty_static->getNomUrl(1); + print "'; + if ($thirdparty_static->client == 1 || $thirdparty_static->client == 3) + { + $thirdparty_static->name = $langs->trans("Customer"); + print $thirdparty_static->getNomUrl(0, 'customer', 0, 1); + } + if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; + if (($thirdparty_static->client == 2 || $thirdparty_static->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + $thirdparty_static->name = $langs->trans("Prospect"); + print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1); + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $thirdparty_static->fournisseur) + { + if ($thirdparty_static->client) print " / "; + $thirdparty_static->name = $langs->trans("Supplier"); + print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1); + } + print ''; + print dol_print_date($thirdparty_static->date_modification, 'day'); + print "'; + print $thirdparty_static->getLibStatut(3); + print "
\n"; + print ''; + print "\n"; + } +} +else +{ + dol_print_error($db); +} + +//print ''; +print ''; @@ -416 +347 @@ -$reshook = $hookmanager->executeHooks('dashboardThirdparties', $parameters, $thirdparty_static); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('dashboardThirdparties', $parameters, $object); // Note that $action and $object may have been modified by hook --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_list.php @@ -13,4 +13 @@ - * Copyright (C) 2020 Open-Dsi - * Copyright (C) 2021 Frédéric France - * Copyright (C) 2022 Anthony Berton - * Copyright (C) 2023 William Mead + @@ -38,2 +34,0 @@ - -// Load Dolibarr environment @@ -48,2 +42,0 @@ - -// Load translation files required by the page @@ -52,3 +45 @@ - -// Get parameters -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -57,11 +48,15 @@ -$confirm = GETPOST('confirm', 'alpha'); -$toselect = GETPOST('toselect', 'array'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'thirdpartylist'; -$optioncss = GETPOST('optioncss', 'alpha'); -if ($contextpage == 'poslist') { - $optioncss = 'print'; -} -$mode = GETPOST("mode", 'alpha'); - -// search fields -$search_all = trim(GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartylist'; + +if ($contextpage == 'poslist') +{ + $_GET['optioncss'] = 'print'; +} + +// Security check +$socid = GETPOST('socid', 'int'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'societe', $socid, ''); + +$search_all = trim(GETPOST('search_all', 'alphanohtml') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -71,3 +66,3 @@ -$search_nom = trim(GETPOST("search_nom", 'restricthtml')); -$search_alias = trim(GETPOST("search_alias", 'restricthtml')); -$search_nom_only = trim(GETPOST("search_nom_only", 'restricthtml')); +$search_nom = trim(GETPOST("search_nom", 'none')); +$search_alias = trim(GETPOST("search_alias", 'none')); +$search_nom_only = trim(GETPOST("search_nom_only", 'none')); @@ -79 +74 @@ -$search_address = trim(GETPOST('search_address', 'alpha')); +$search_town = trim(GETPOST("search_town", 'alpha')); @@ -81 +75,0 @@ -$search_town = trim(GETPOST("search_town", 'alpha')); @@ -95,3 +89,3 @@ -$search_sale = GETPOST("search_sale", 'int'); -$search_categ_cus = GETPOST("search_categ_cus", 'int'); -$search_categ_sup = GETPOST("search_categ_sup", 'int'); +$search_sale = trim(GETPOST("search_sale", 'int')); +$search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); +$search_categ_sup = trim(GETPOST("search_categ_sup", 'int')); @@ -100 +93,0 @@ -$search_price_level = GETPOST('search_price_level', 'int'); @@ -104,23 +97,4 @@ -$search_level = GETPOST("search_level", "array:alpha"); -$search_stcomm = GETPOST('search_stcomm', "array:int"); -$search_import_key = trim(GETPOST("search_import_key", "alpha")); -$search_parent_name = trim(GETPOST('search_parent_name', 'alpha')); - -$search_date_creation_startmonth = GETPOST('search_date_creation_startmonth', 'int'); -$search_date_creation_startyear = GETPOST('search_date_creation_startyear', 'int'); -$search_date_creation_startday = GETPOST('search_date_creation_startday', 'int'); -$search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear); // Use tzserver -$search_date_creation_endmonth = GETPOST('search_date_creation_endmonth', 'int'); -$search_date_creation_endyear = GETPOST('search_date_creation_endyear', 'int'); -$search_date_creation_endday = GETPOST('search_date_creation_endday', 'int'); -$search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear); // Use tzserver - -$search_date_modif_startmonth = GETPOST('search_date_modif_startmonth', 'int'); -$search_date_modif_startyear = GETPOST('search_date_modif_startyear', 'int'); -$search_date_modif_startday = GETPOST('search_date_modif_startday', 'int'); -$search_date_modif_start = dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear); // Use tzserver -$search_date_modif_endmonth = GETPOST('search_date_modif_endmonth', 'int'); -$search_date_modif_endyear = GETPOST('search_date_modif_endyear', 'int'); -$search_date_modif_endday = GETPOST('search_date_modif_endday', 'int'); -$search_date_modif_end = dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear); // Use tzserver - +$search_level = GETPOST("search_level", "array"); +$search_stcomm = GETPOST('search_stcomm', 'int'); +$search_import_key = GETPOST("search_import_key", "alpha"); +$search_parent_name = GETPOST('search_parent_name', 'alpha'); @@ -128,0 +103,2 @@ +$optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST("mode", 'alpha'); @@ -133,4 +109,3 @@ -// Load variable for pagination -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -138,10 +113,3 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "s.nom"; -} -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action @@ -152,34 +120,5 @@ -if ($type == 'c') { - if (empty($contextpage) || $contextpage == 'thirdpartylist') { - $contextpage = 'customerlist'; - } - if ($search_type == '') { - $search_type = '1,3'; - } -} -if ($type == 'p') { - if (empty($contextpage) || $contextpage == 'thirdpartylist') { - $contextpage = 'prospectlist'; - } - if ($search_type == '') { - $search_type = '2,3'; - } -} -if ($type == 't') { - if (empty($contextpage) || $contextpage == 'poslist') { - $contextpage = 'poslist'; - } - if ($search_type == '') { - $search_type = '1,2,3'; - } -} -if ($type == 'f') { - if (empty($contextpage) || $contextpage == 'thirdpartylist') { - $contextpage = 'supplierlist'; - } - if ($search_type == '') { - $search_type = '4'; - } -} - -// Initialize technical objects to manage hooks of page. Note that conf->hooks_modules contains array of hook context +if ($type == 'c') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'customerlist'; if ($search_type == '') $search_type = '1,3'; } +if ($type == 'p') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'prospectlist'; if ($search_type == '') $search_type = '2,3'; } +if ($type == 'f') { if (empty($contextpage) || $contextpage == 'thirdpartylist') $contextpage = 'supplierlist'; if ($search_type == '') $search_type = '4'; } + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -186,0 +126 @@ +$hookmanager->initHooks(array('thirdpartylist')); @@ -188,3 +128,2 @@ -$hookmanager->initHooks(array($contextpage)); - -// Fetch optionals attributes and labels + +// fetch optionals attributes and labels @@ -203,2 +141,0 @@ - 's.zip'=>"Zip", - 's.town'=>"Town", @@ -214,12 +151,4 @@ -if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') { - $fieldstosearchall['s.idprof4'] = 'ProfId4'; -} -if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') { - $fieldstosearchall['s.idprof5'] = 'ProfId5'; -} -if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') { - $fieldstosearchall['s.idprof6'] = 'ProfId6'; -} -if (isModEnabled('barcode')) { - $fieldstosearchall['s.barcode'] = 'Gencod'; -} +if (($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof4'] = 'ProfId4'; +if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof5'] = 'ProfId5'; +if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6'] = 'ProfId6'; +if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode'] = 'Gencod'; @@ -227,3 +156 @@ -if (getDolGlobalString('THIRDPARTY_QUICKSEARCH_ON_FIELDS')) { - $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); -} +if (!empty($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS)) $fieldstosearchall = dolExplodeIntoArray($conf->global->THIRDPARTY_QUICKSEARCH_ON_FIELDS); @@ -250 +177 @@ - 's.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>-1, 'enabled'=>1), + 's.rowid'=>array('label'=>"TechnicalID", 'position'=>1, 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0)), @@ -253 +180 @@ - 's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(isModEnabled('barcode'))), + 's.barcode'=>array('label'=>"Gencod", 'position'=>5, 'checked'=>1, 'enabled'=>(!empty($conf->barcode->enabled))), @@ -255 +182 @@ - 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), + 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), @@ -257,4 +184,3 @@ - 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))), - 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0), - 's.zip'=>array('label'=>"Zip", 'position'=>20, 'checked'=>1), - 's.town'=>array('label'=>"Town", 'position'=>21, 'checked'=>0), + 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>1), + 's.zip'=>array('label'=>"Zip", 'position'=>21, 'checked'=>1), @@ -269 +195 @@ - 'staff.code'=>array('label'=>"Workforce", 'position'=>31, 'checked'=>0), + 'staff.code'=>array('label'=>"Staff", 'position'=>30, 'checked'=>0), @@ -278 +204 @@ - 's.fk_prospectlevel'=>array('label'=>"ProspectLevel", 'position'=>62, 'checked'=>$checkprospectlevel), + 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'position'=>62, 'checked'=>$checkprospectlevel), @@ -286,7 +211,0 @@ -if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) { - $arrayfields['s.price_level'] = array('label'=>"PriceLevel", 'position'=>30, 'checked'=>0); -} - -// Add non object fields to fields for list -$arrayfields['sales.representative'] = array('label'=>$langs->trans("SalesRepresentatives"), 'checked'=>1, 'position'=>12); - @@ -294,2 +213,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -298,8 +222,0 @@ - -// Security check -$socid = GETPOST('socid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'societe', $socid, ''); - @@ -312,4 +229,5 @@ -if ($action == "change" && $user->hasRight('takepos', 'run')) { // Change customer for TakePOS - $idcustomer = GETPOST('idcustomer', 'int'); - - // Check if draft invoice already exists, if not create it +if ($action == "change") // Change customer for TakePOS +{ + $idcustomer = GETPOST('idcustomer', 'int'); + + // Check if draft invoice already exists, if not create it @@ -319 +237,2 @@ - if ($num_lines == 0) { + if ($num_lines == 0) + { @@ -323 +242 @@ - $invoice->socid = getDolGlobalInt($constforthirdpartyid); + $invoice->socid = $conf->global->$constforthirdpartyid; @@ -328 +247 @@ - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid = ".((int) $placeid); + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' where rowid=".$placeid; @@ -332,6 +251,7 @@ - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; - $resql = $db->query($sql); ?> - - + error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -366,2 +280,3 @@ - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + // Did we click on purge search criteria ? + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { @@ -379 +294 @@ - $search_address = ''; + $search_town = ""; @@ -381 +295,0 @@ - $search_town = ""; @@ -383 +296,0 @@ - $search_region = ""; @@ -397 +309,0 @@ - $search_price_level = ''; @@ -400,16 +311,0 @@ - $search_date_creation_startmonth = ""; - $search_date_creation_startyear = ""; - $search_date_creation_startday = ""; - $search_date_creation_start = ""; - $search_date_creation_endmonth = ""; - $search_date_creation_endyear = ""; - $search_date_creation_endday = ""; - $search_date_creation_end = ""; - $search_date_modif_startmonth = ""; - $search_date_modif_startyear = ""; - $search_date_modif_startday = ""; - $search_date_modif_start = ""; - $search_date_modif_endmonth = ""; - $search_date_modif_endyear = ""; - $search_date_modif_endday = ""; - $search_date_modif_end = ""; @@ -418,4 +314,4 @@ - $search_level = ''; - $search_parent_name = ''; - $search_import_key = ''; - $toselect = array(); + $search_level = ''; + $search_parent_name = ''; + $search_import_key = ''; + $toselect = ''; @@ -428,3 +324,2 @@ - $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->hasRight('societe', 'supprimer'); - $permissiontoadd = $user->hasRight("societe", "creer"); + $permissiontoread = $user->rights->societe->lire; + $permissiontodelete = $user->rights->societe->supprimer; @@ -434 +329,2 @@ - if ($action == 'setstcomm') { + if ($action == 'setstcomm') + { @@ -439,3 +335 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -447,3 +341 @@ -if ($search_status == '') { - $search_status = 1; // always display active thirdparty first -} +if ($search_status == '') $search_status = 1; // always display active thirdparty first @@ -475,14 +367,5 @@ -$now = dol_now(); - -$title = $langs->trans("ThirdParties"); -if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) { - $title = $langs->trans("Customers"); -} -if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) { - $title = $langs->trans("Prospects"); -} -if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) { - $title = $langs->trans("Suppliers"); -} -$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; - + +$title = $langs->trans("ListOfThirdParties"); +if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title = $langs->trans("ListOfCustomers"); +if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title = $langs->trans("ListOfProspects"); +if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title = $langs->trans("ListOfSuppliers"); @@ -497,2 +380,4 @@ -if ($resql) { - while ($obj = $db->fetch_object($resql)) { +if ($resql) +{ + while ($obj = $db->fetch_object($resql)) + { @@ -501,3 +386 @@ - if ($level == $obj->code) { - $level = $langs->trans($obj->label); - } + if ($level == $obj->code) $level = $langs->trans($obj->label); @@ -506,7 +389,4 @@ -} else { - dol_print_error($db); -} - -// Build and execute select -// -------------------------------------------------------------------- -$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; +} +else dol_print_error($db); + +$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; @@ -514 +394 @@ -$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; +$sql .= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; @@ -516,2 +396,2 @@ -$sql .= " s.tms as date_update, s.datec as date_creation, s.import_key,"; -$sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,s.price_level,"; +$sql .= " s.tms as date_update, s.datec as date_creation,"; +$sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; @@ -525,3 +405,4 @@ -if ($search_sale && $search_sale != '-1') { - $sql .= ", sc.fk_soc, sc.fk_user"; -} +if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; +// We'll need these fields in order to filter by categ +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; +if ($search_categ_sup) $sql .= ", cs.fk_categorie, cs.fk_soc"; @@ -530,3 +411 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -536 +415 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -538,5 +416,0 @@ -$sql = preg_replace('/,\s*$/', '', $sql); -//$sql .= ", COUNT(rc.rowid) as anotherfield"; - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -545,4 +419 @@ -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; -} - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)"; @@ -553 +424,4 @@ -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region.code_region = state.fk_region)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)"; +// We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ_cus)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ_sup)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ @@ -556,10 +430,2 @@ -if ($search_sale == -2) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - //elseif ($search_sale || (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} elseif (!empty($search_sale) && $search_sale != '-1' || (!$user->hasRight('societe', 'client', 'voir') && !$socid)) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; +elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -567,162 +433,38 @@ -//if (empty($user->rights->societe->client->voir) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->societe->client->readallthirdparties_advance)) && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} -if ($search_sale && $search_sale != '-1' && $search_sale != '-2') { - $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale -} -if (!$user->hasRight('fournisseur', 'lire')) { - $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible -} -if ($search_sale == -2) { - $sql .= " AND sc.fk_user IS NULL"; -} elseif ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".((int) $search_sale); -} -$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array(); -$searchCategoryCustomerOperator = 0; -// Search for tag/category ($searchCategoryCustomerList is an array of ID) -if (!empty($searchCategoryCustomerList)) { - $searchCategoryCustomerSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { - if (intval($searchCategoryCustomer) == -2) { - $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)"; - } elseif (intval($searchCategoryCustomer) > 0) { - if ($searchCategoryCustomerOperator == 0) { - $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer); - } - } - } - if ($listofcategoryid) { - $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategoryCustomerOperator == 1) { - if (!empty($searchCategoryCustomerSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")"; - } - } else { - if (!empty($searchCategoryCustomerSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")"; - } - } -} -// Search Supplier Categories -$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array(); -$searchCategorySupplierOperator = 0; -// Search for tag/category ($searchCategorySupplierList is an array of ID) -if (!empty($searchCategorySupplierList)) { - $searchCategorySupplierSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategorySupplierList as $searchCategorySupplier) { - if (intval($searchCategorySupplier) == -2) { - $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)"; - } elseif (intval($searchCategorySupplier) > 0) { - if ($searchCategorySupplierOperator == 0) { - $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier); - } - } - } - if ($listofcategoryid) { - $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategorySupplierOperator == 1) { - if (!empty($searchCategorySupplierSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")"; - } - } else { - if (!empty($searchCategorySupplierSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")"; - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -if (strlen($search_cti)) { - $sql .= natural_search('s.phone', $search_cti); -} -if ($search_id > 0) { - $sql .= natural_search("s.rowid", $search_id, 1); -} -if (empty($arrayfields['s.name_alias']['checked']) && $search_nom) { - $sql .= natural_search(array("s.nom", "s.name_alias"), $search_nom); -} else { - if ($search_nom) { - $sql .= natural_search("s.nom", $search_nom); - } - - if ($search_alias) { - $sql .= natural_search("s.name_alias", $search_alias); - } -} -if ($search_nom_only) { - $sql .= natural_search("s.nom", $search_nom_only); -} -if ($search_customer_code) { - $sql .= natural_search("s.code_client", $search_customer_code); -} -if ($search_supplier_code) { - $sql .= natural_search("s.code_fournisseur", $search_supplier_code); -} -if ($search_account_customer_code) { - $sql .= natural_search("s.code_compta", $search_account_customer_code); -} -if ($search_account_supplier_code) { - $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); -} -if ($search_address) { - $sql .= natural_search('s.address', $search_address); -} -if (strlen($search_zip)) { - $sql .= natural_search("s.zip", $search_zip); -} -if ($search_town) { - $sql .= natural_search("s.town", $search_town); -} -if ($search_state) { - $sql .= natural_search("state.nom", $search_state); -} -if ($search_region) { - $sql .= natural_search("region.nom", $search_region); -} -if ($search_country && $search_country != '-1') { - $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; -} -if ($search_email) { - $sql .= natural_search("s.email", $search_email); -} -if (strlen($search_phone)) { - $sql .= natural_search("s.phone", $search_phone); -} -if (strlen($search_fax)) { - $sql .= natural_search("s.fax", $search_fax); -} -if ($search_url) { - $sql .= natural_search("s.url", $search_url); -} -if (strlen($search_idprof1)) { - $sql .= natural_search("s.siren", $search_idprof1); -} -if (strlen($search_idprof2)) { - $sql .= natural_search("s.siret", $search_idprof2); -} -if (strlen($search_idprof3)) { - $sql .= natural_search("s.ape", $search_idprof3); -} -if (strlen($search_idprof4)) { - $sql .= natural_search("s.idprof4", $search_idprof4); -} -if (strlen($search_idprof5)) { - $sql .= natural_search("s.idprof5", $search_idprof5); -} -if (strlen($search_idprof6)) { - $sql .= natural_search("s.idprof6", $search_idprof6); -} -if (strlen($search_vat)) { - $sql .= natural_search("s.tva_intra", $search_vat); -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND s.rowid = ".$socid; +if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible +if ($search_sale == -2) $sql .= " AND sc.fk_user IS NULL"; +elseif ($search_sale) $sql .= " AND sc.fk_user = ".$db->escape($search_sale); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_sup > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ_sup); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; +if ($search_categ_sup == -2) $sql .= " AND cs.fk_categorie IS NULL"; + +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +if (strlen($search_cti)) $sql .= natural_search('s.phone', $search_cti); + +if ($search_id > 0) $sql .= natural_search("s.rowid", $search_id, 1); +if ($search_nom) $sql .= natural_search("s.nom", $search_nom); +if ($search_alias) $sql .= natural_search("s.name_alias", $search_alias); +if ($search_nom_only) $sql .= natural_search("s.nom", $search_nom_only); +if ($search_customer_code) $sql .= natural_search("s.code_client", $search_customer_code); +if ($search_supplier_code) $sql .= natural_search("s.code_fournisseur", $search_supplier_code); +if ($search_account_customer_code) $sql .= natural_search("s.code_compta", $search_account_customer_code); +if ($search_account_supplier_code) $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); +if ($search_town) $sql .= natural_search("s.town", $search_town); +if (strlen($search_zip)) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); +if ($search_region) $sql .= natural_search("region.nom", $search_region); +if ($search_country && $search_country != '-1') $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; +if ($search_email) $sql .= natural_search("s.email", $search_email); +if (strlen($search_phone)) $sql .= natural_search("s.phone", $search_phone); +if (strlen($search_fax)) $sql .= natural_search("s.fax", $search_fax); +if ($search_url) $sql .= natural_search("s.url", $search_url); +if (strlen($search_idprof1)) $sql .= natural_search("s.siren", $search_idprof1); +if (strlen($search_idprof2)) $sql .= natural_search("s.siret", $search_idprof2); +if (strlen($search_idprof3)) $sql .= natural_search("s.ape", $search_idprof3); +if (strlen($search_idprof4)) $sql .= natural_search("s.idprof4", $search_idprof4); +if (strlen($search_idprof5)) $sql .= natural_search("s.idprof5", $search_idprof5); +if (strlen($search_idprof6)) $sql .= natural_search("s.idprof6", $search_idprof6); +if (strlen($search_vat)) $sql .= natural_search("s.tva_intra", $search_vat); @@ -730,50 +472,11 @@ -if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) { - $sql .= " AND s.client IN (".$db->sanitize($search_type).")"; -} -if ($search_type > 0 && in_array($search_type, array('4'))) { - $sql .= " AND s.fournisseur = 1"; -} -if ($search_type == '0') { - $sql .= " AND s.client = 0 AND s.fournisseur = 0"; -} -if ($search_status != '' && $search_status >= 0) { - $sql .= natural_search("s.status", $search_status, 2); -} -if (isModEnabled('barcode') && $search_barcode) { - $sql .= natural_search("s.barcode", $search_barcode); -} -if ($search_price_level && $search_price_level != '-1') { - $sql .= natural_search("s.price_level", $search_price_level, 2); -} -if ($search_type_thirdparty && $search_type_thirdparty > 0) { - $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2); -} -if (!empty($search_staff) && $search_staff != '-1') { - $sql .= natural_search("s.fk_effectif", $search_staff, 2); -} -if ($search_parent_name) { - $sql .= natural_search("s2.nom", $search_parent_name); -} -if ($search_level) { - $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); -} -if ($search_stcomm) { - $sql .= natural_search("s.fk_stcomm", join(',', $search_stcomm), 2); -} -if ($search_import_key) { - $sql .= natural_search("s.import_key", $search_import_key); -} -if ($search_date_creation_start) { - $sql .= " AND s.datec >= '".$db->idate($search_date_creation_start)."'"; -} -if ($search_date_creation_end) { - $sql .= " AND s.datec <= '".$db->idate($search_date_creation_end)."'"; -} - -if ($search_date_modif_start) { - $sql .= " AND s.tms >= '".$db->idate($search_date_modif_start)."'"; -} -if ($search_date_modif_end) { - $sql .= " AND s.tms <= '".$db->idate($search_date_modif_end)."'"; -} - +if ($search_type > 0 && in_array($search_type, array('1,3', '2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")"; +if ($search_type > 0 && in_array($search_type, array('4'))) $sql .= " AND s.fournisseur = 1"; +if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0"; +if ($search_status != '' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2); +if (!empty($conf->barcode->enabled) && $search_barcode) $sql .= natural_search("s.barcode", $search_barcode); +if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2); +if (!empty($search_staff) && $search_staff != '-1') $sql .= natural_search("s.fk_effectif", $search_staff, 2); +if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3); +if ($search_parent_name) $sql .= natural_search("s2.nom", $search_parent_name); +if ($search_stcomm != '' && $search_stcomm != -2) $sql .= natural_search("s.fk_stcomm", $search_stcomm, 2); +if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key); @@ -781,0 +485 @@ + @@ -783,7 +487,2 @@ -$parameters = array('socid' => $socid); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - if ($socid) { - $sql .= " AND s.rowid = ".((int) $socid); - } -} +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -792,4 +491 @@ -// Add GroupBy from hooks -$parameters = array('fieldstosearchall' => $fieldstosearchall); -$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +$sql .= $db->order($sortfield, $sortorder); @@ -799,13 +495,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -815,8 +504,3 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} +} + +$sql .= $db->plimit($limit + 1, $offset); @@ -825 +509,2 @@ -if (!$resql) { +if (!$resql) +{ @@ -832,26 +516,0 @@ - -// Direct jump if only one record found -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && ($search_all != '' || $search_cti != '') && $action != 'list') { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - if (getDolGlobalString('SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD')) { - if ($obj->client > 0) { - header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id); - exit; - } - if ($obj->fournisseur > 0) { - header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id); - exit; - } - } - - header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id); - exit; -} - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url); - - @@ -859,0 +519,21 @@ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) { + if ($obj->client > 0) { + header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id); + exit; + } + if ($obj->fournisseur > 0) { + header("Location: ".DOL_URL_ROOT.'/fourn/card.php?socid='.$id); + exit; + } + } + + header("Location: ".DOL_URL_ROOT.'/societe/card.php?socid='.$id); + exit; +} + +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('', $langs->trans("ThirdParty"), $help_url); + @@ -861,179 +541,38 @@ -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -if ($search_all != '') { - $param = "&search_all=".urlencode($search_all); -} -if ($search_categ_cus > 0) { - $param .= '&search_categ_cus='.urlencode($search_categ_cus); -} -if ($search_categ_sup > 0) { - $param .= '&search_categ_sup='.urlencode($search_categ_sup); -} -if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); -} -if ($search_id > 0) { - $param .= "&search_id=".urlencode($search_id); -} -if ($search_nom != '') { - $param .= "&search_nom=".urlencode($search_nom); -} -if ($search_alias != '') { - $param .= "&search_alias=".urlencode($search_alias); -} -if ($search_address != '') { - $param .= '&search_address='.urlencode($search_address); -} -if ($search_zip != '') { - $param .= "&search_zip=".urlencode($search_zip); -} -if ($search_town != '') { - $param .= "&search_town=".urlencode($search_town); -} -if ($search_phone != '') { - $param .= "&search_phone=".urlencode($search_phone); -} -if ($search_fax != '') { - $param .= "&search_fax=".urlencode($search_fax); -} -if ($search_email != '') { - $param .= "&search_email=".urlencode($search_email); -} -if ($search_url != '') { - $param .= "&search_url=".urlencode($search_url); -} -if ($search_state != '') { - $param .= "&search_state=".urlencode($search_state); -} -if ($search_region != '') { - $param .= "&search_region=".urlencode($search_region); -} -if ($search_country != '') { - $param .= "&search_country=".urlencode($search_country); -} -if ($search_customer_code != '') { - $param .= "&search_customer_code=".urlencode($search_customer_code); -} -if ($search_supplier_code != '') { - $param .= "&search_supplier_code=".urlencode($search_supplier_code); -} -if ($search_account_customer_code != '') { - $param .= "&search_account_customer_code=".urlencode($search_account_customer_code); -} -if ($search_account_supplier_code != '') { - $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code); -} -if ($search_barcode != '') { - $param .= "&search_barcode=".urlencode($search_barcode); -} -if ($search_idprof1 != '') { - $param .= '&search_idprof1='.urlencode($search_idprof1); -} -if ($search_idprof2 != '') { - $param .= '&search_idprof2='.urlencode($search_idprof2); -} -if ($search_idprof3 != '') { - $param .= '&search_idprof3='.urlencode($search_idprof3); -} -if ($search_idprof4 != '') { - $param .= '&search_idprof4='.urlencode($search_idprof4); -} -if ($search_idprof5 != '') { - $param .= '&search_idprof5='.urlencode($search_idprof5); -} -if ($search_idprof6 != '') { - $param .= '&search_idprof6='.urlencode($search_idprof6); -} -if ($search_vat != '') { - $param .= '&search_vat='.urlencode($search_vat); -} -if ($search_price_level != '') { - $param .= '&search_price_level='.urlencode($search_price_level); -} -if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); -} -if ($search_type != '') { - $param .= '&search_type='.urlencode($search_type); -} -if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); -} -if (is_array($search_level) && count($search_level)) { - foreach ($search_level as $slevel) { - $param .= '&search_level[]='.urlencode($slevel); - } -} -if (is_array($search_stcomm) && count($search_stcomm)) { - foreach ($search_stcomm as $slevel) { - $param .= '&search_stcomm[]='.urlencode($slevel); - } -} -if ($search_parent_name != '') { - $param .= '&search_parent_name='.urlencode($search_parent_name); -} -if ($search_import_key != '') { - $param .= '&search_import_key='.urlencode($search_import_key); -} -if ($type != '') { - $param .= '&type='.urlencode($type); -} -if ($search_date_creation_startmonth) { - $param .= '&search_date_creation_startmonth='.urlencode($search_date_creation_startmonth); -} -if ($search_date_creation_startyear) { - $param .= '&search_date_creation_startyear='.urlencode($search_date_creation_startyear); -} -if ($search_date_creation_startday) { - $param .= '&search_date_creation_startday='.urlencode($search_date_creation_startday); -} -if ($search_date_creation_start) { - $param .= '&search_date_creation_start='.urlencode($search_date_creation_start); -} -if ($search_date_creation_endmonth) { - $param .= '&search_date_creation_endmonth='.urlencode($search_date_creation_endmonth); -} -if ($search_date_creation_endyear) { - $param .= '&search_date_creation_endyear='.urlencode($search_date_creation_endyear); -} -if ($search_date_creation_endday) { - $param .= '&search_date_creation_endday='.urlencode($search_date_creation_endday); -} -if ($search_date_creation_end) { - $param .= '&search_date_creation_end='.urlencode($search_date_creation_end); -} -if ($search_date_modif_startmonth) { - $param .= '&search_date_modif_startmonth='.urlencode($search_date_modif_startmonth); -} -if ($search_date_modif_startyear) { - $param .= '&search_date_modif_startyear='.urlencode($search_date_modif_startyear); -} -if ($search_date_modif_startday) { - $param .= '&search_date_modif_startday='.urlencode($search_date_modif_startday); -} -if ($search_date_modif_start) { - $param .= '&search_date_modif_start='.urlencode($search_date_modif_start); -} -if ($search_date_modif_endmonth) { - $param .= '&search_date_modif_endmonth='.urlencode($search_date_modif_endmonth); -} -if ($search_date_modif_endyear) { - $param .= '&search_date_modif_endyear='.urlencode($search_date_modif_endyear); -} -if ($search_date_modif_endday) { - $param .= '&search_date_modif_endday='.urlencode($search_date_modif_endday); -} -if ($search_date_modif_end) { - $param .= '&search_date_modif_end=' . urlencode($search_date_modif_end); -} - +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_all != '') $param = "&sall=".urlencode($search_all); +if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); +if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup); +if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); +if ($search_id > 0) $param .= "&search_id=".urlencode($search_id); +if ($search_nom != '') $param .= "&search_nom=".urlencode($search_nom); +if ($search_alias != '') $param .= "&search_alias=".urlencode($search_alias); +if ($search_town != '') $param .= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip); +if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone); +if ($search_fax != '') $param .= "&search_fax=".urlencode($search_fax); +if ($search_email != '') $param .= "&search_email=".urlencode($search_email); +if ($search_url != '') $param .= "&search_url=".urlencode($search_url); +if ($search_state != '') $param .= "&search_state=".urlencode($search_state); +if ($search_country != '') $param .= "&search_country=".urlencode($search_country); +if ($search_customer_code != '') $param .= "&search_customer_code=".urlencode($search_customer_code); +if ($search_supplier_code != '') $param .= "&search_supplier_code=".urlencode($search_supplier_code); +if ($search_account_customer_code != '') $param .= "&search_account_customer_code=".urlencode($search_account_customer_code); +if ($search_account_supplier_code != '') $param .= "&search_account_supplier_code=".urlencode($search_account_supplier_code); +if ($search_barcode != '') $param .= "&search_barcode=".urlencode($search_barcode); +if ($search_idprof1 != '') $param .= '&search_idprof1='.urlencode($search_idprof1); +if ($search_idprof2 != '') $param .= '&search_idprof2='.urlencode($search_idprof2); +if ($search_idprof3 != '') $param .= '&search_idprof3='.urlencode($search_idprof3); +if ($search_idprof4 != '') $param .= '&search_idprof4='.urlencode($search_idprof4); +if ($search_idprof5 != '') $param .= '&search_idprof5='.urlencode($search_idprof5); +if ($search_idprof6 != '') $param .= '&search_idprof6='.urlencode($search_idprof6); +if ($search_vat != '') $param .= '&search_vat='.urlencode($search_vat); +if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); +if ($search_type != '') $param .= '&search_type='.urlencode($search_type); +if (is_array($search_level) && count($search_level)) foreach ($search_level as $slevel) $param .= '&search_level[]='.urlencode($slevel); +if ($search_status != '') $param .= '&search_status='.urlencode($search_status); +if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm); +if ($search_parent_name != '') $param .= '&search_parent_name='.urlencode($search_parent_name); +if ($search_import_key != '') $param .= '&search_import_key='.urlencode($search_import_key); +if ($type != '') $param .= '&type='.urlencode($type); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -1042,4 +580,0 @@ -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; @@ -1048 +583,2 @@ -if (GETPOST('delsoc')) { +if (GETPOST('delsoc')) +{ @@ -1054,2 +590,2 @@ - 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), @@ -1058,18 +594,2 @@ -if (isModEnabled('category') && $user->hasRight("societe", "creer")) { - $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); -} -if ($user->hasRight("societe", "creer")) { - $arrayofmassactions['preenable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_INACTIVITY)); -} -if ($user->hasRight("societe", "creer")) { - $arrayofmassactions['predisable'] = img_picto('', 'stop-circle', 'class="pictofixedwidth"').$langs->trans("SetToStatus", $object->LibStatut($object::STATUS_CEASED)); -} -if ($user->hasRight("societe", "creer")) { - $arrayofmassactions['presetcommercial'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("AllocateCommercial"); -} -if ($user->hasRight('societe', 'supprimer')) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { - $arrayofmassactions = array(); -} +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -1078,41 +598,19 @@ -$typefilter = ''; -$label = 'MenuNewThirdParty'; - -if (!empty($type)) { - $typefilter = '&type='.$type; - if ($type == 'p') { - $label = 'MenuNewProspect'; - } - if ($type == 'c') { - $label = 'MenuNewCustomer'; - } - if ($type == 'f') { - $label = 'NewSupplier'; - } -} - -if ($contextpage == 'poslist' && $type == 't' && (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'))) { - print get_htmloutput_mesg(img_warning('default').' '.$langs->trans("BecarefullChangeThirdpartyBeforeAddProductToInvoice"), '', 'warning', 1); -} - -// Show the new button only when this page is not opend from the Extended POS (pop-up window) -// but allow it too, when a user has the rights to create a new customer -if ($contextpage != 'poslist') { - $url = DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter; - if (!empty($socid)) { - $url .= '&socid='.$socid; - } - $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->hasRight('societe', 'creer')); -} elseif ($user->hasRight('societe', 'creer')) { - $url = DOL_URL_ROOT.'/societe/card.php?action=create&type=t&contextpage=poslist&optioncss=print&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type=t&contextpage=poslist&nomassaction=1&optioncss=print&place='.$place); - $label = 'MenuNewCustomer'; - $newcardbutton = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url); -} - -print '
'."\n"; -if ($optioncss != '') { - print ''; -} +$newcardbutton = ''; +if ($user->rights->societe->creer && $contextpage != 'poslist') +{ + $typefilter = ''; + $label = 'MenuNewThirdParty'; + + if (!empty($type)) + { + $typefilter = '&type='.$type; + if ($type == 'p') $label = 'MenuNewProspect'; + if ($type == 'c') $label = 'MenuNewCustomer'; + if ($type == 'f') $label = 'NewSupplier'; + } + + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/societe/card.php?action=create'.$typefilter); +} + +print ''; +if ($optioncss != '') print ''; @@ -1121 +618,0 @@ -print ''; @@ -1126,11 +622,0 @@ -if (!empty($place)) { - print ''; -} -print ''; -print ''; -if (empty($arrayfields['customerorsupplier']['checked'])) { - print ''; -} -if (!empty($place)) { - print ''; -} @@ -1142 +628,2 @@ -foreach (array(1, 2, 3, 4, 5, 6) as $key) { +foreach (array(1, 2, 3, 4, 5, 6) as $key) +{ @@ -1145,4 +632,3 @@ - if ($label != "ProfId".$key.$mysoc->country_code) { // Get only text between () - if (preg_match('/\((.*)\)/i', $label, $reg)) { - $label = $reg[1]; - } + if ($label != "ProfId".$key.$mysoc->country_code) + { // Get only text between () + if (preg_match('/\((.*)\)/i', $label, $reg)) $label = $reg[1]; @@ -1153 +638,0 @@ -// Add code for pre mass action (confirmation or email presend form) @@ -1160,7 +645,3 @@ -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; +if ($search_all) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -1169,0 +651 @@ +// Filter on categories @@ -1171,2 +653,4 @@ -if (empty($type) || $type == 'c' || $type == 'p') { - if (isModEnabled('categorie') && $user->hasRight("categorie", "lire")) { +if (empty($type) || $type == 'c' || $type == 'p') +{ + if (!empty($conf->categorie->enabled)) + { @@ -1175,2 +659 @@ - $tmptitle = $langs->trans('Categories'); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $langs->trans('CustomersProspectsCategoriesShort').': '; @@ -1178,6 +661,7 @@ - $moreforfilter .= ''; - } -} - -if (empty($type) || $type == 'f') { - if (isModEnabled("fournisseur") && isModEnabled('categorie') && $user->hasRight("categorie", "lire")) { + $moreforfilter .= ''; + } +} +if (empty($type) || $type == 'f') +{ + if (!empty($conf->categorie->enabled)) + { @@ -1186,3 +670,2 @@ - $tmptitle = $langs->trans('Categories'); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1, $langs->trans('SuppliersCategoriesShort')); + $moreforfilter .= $langs->trans('SuppliersCategoriesShort').': '; + $moreforfilter .= $formother->select_categories('supplier', $search_categ_sup, 'search_categ_sup', 1); @@ -1194,5 +677,5 @@ -if ($user->hasRight("societe", "client", "voir") || $socid) { - $moreforfilter .= '
'; - $tmptitle = $langs->trans('SalesRepresentatives'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"'); - $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $langs->trans('SalesRepresentatives'), ($conf->dol_optimize_smallscreen ? 'maxwidth200' : 'maxwidth300'), 1); +if ($user->rights->societe->client->voir || $socid) +{ + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans('SalesRepresentatives').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300', 1); @@ -1201 +684,2 @@ -if (!empty($moreforfilter)) { +if ($moreforfilter) +{ @@ -1205 +689 @@ - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -1211,6 +695,7 @@ -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields -//$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields -$selectedfields .= ((count($arrayofmassactions) && $contextpage != 'poslist') ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + +if (empty($arrayfields['customerorsupplier']['checked'])) print ''; + +print '
'; +print '
'."\n"; @@ -1219 +703,0 @@ -// -------------------------------------------------------------------- @@ -1221,9 +705,3 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} -if (!empty($arrayfields['s.rowid']['checked'])) { - print ''; -} -// Sales representatives -if (!empty($arrayfields['sales.representative']['checked'])) { - print ''; -} @@ -1300 +774,2 @@ -if (!empty($arrayfields['state.nom']['checked'])) { +if (!empty($arrayfields['state.nom']['checked'])) +{ @@ -1306 +781,2 @@ -if (!empty($arrayfields['region.nom']['checked'])) { +if (!empty($arrayfields['region.nom']['checked'])) +{ @@ -1312 +788,2 @@ -if (!empty($arrayfields['country.code_iso']['checked'])) { +if (!empty($arrayfields['country.code_iso']['checked'])) +{ @@ -1318 +795,2 @@ -if (!empty($arrayfields['typent.code']['checked'])) { +if (!empty($arrayfields['typent.code']['checked'])) +{ @@ -1320,8 +798 @@ - // We use showempty=0 here because there is already an unknown value into dictionary. - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'minwidth50 maxwidth125', 1); - print ''; -} -// Multiprice level -if (!empty($arrayfields['s.price_level']['checked'])) { - print ''; -} -if (!empty($arrayfields['s.email']['checked'])) { + print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100'); + print ''; +} +if (!empty($arrayfields['s.email']['checked'])) +{ @@ -1342 +815,2 @@ -if (!empty($arrayfields['s.phone']['checked'])) { +if (!empty($arrayfields['s.phone']['checked'])) +{ @@ -1348 +822,2 @@ -if (!empty($arrayfields['s.fax']['checked'])) { +if (!empty($arrayfields['s.fax']['checked'])) +{ @@ -1354 +829,2 @@ -if (!empty($arrayfields['s.url']['checked'])) { +if (!empty($arrayfields['s.url']['checked'])) +{ @@ -1360 +836,2 @@ -if (!empty($arrayfields['s.siren']['checked'])) { +if (!empty($arrayfields['s.siren']['checked'])) +{ @@ -1366 +843,2 @@ -if (!empty($arrayfields['s.siret']['checked'])) { +if (!empty($arrayfields['s.siret']['checked'])) +{ @@ -1372 +850,2 @@ -if (!empty($arrayfields['s.ape']['checked'])) { +if (!empty($arrayfields['s.ape']['checked'])) +{ @@ -1378 +857,2 @@ -if (!empty($arrayfields['s.idprof4']['checked'])) { +if (!empty($arrayfields['s.idprof4']['checked'])) +{ @@ -1384 +864,2 @@ -if (!empty($arrayfields['s.idprof5']['checked'])) { +if (!empty($arrayfields['s.idprof5']['checked'])) +{ @@ -1390 +871,2 @@ -if (!empty($arrayfields['s.idprof6']['checked'])) { +if (!empty($arrayfields['s.idprof6']['checked'])) +{ @@ -1396 +878,2 @@ -if (!empty($arrayfields['s.tva_intra']['checked'])) { +if (!empty($arrayfields['s.tva_intra']['checked'])) +{ @@ -1403,2 +886,3 @@ -// Nature (customer/prospect/supplier) -if (!empty($arrayfields['customerorsupplier']['checked'])) { +// Type (customer/prospect/supplier) +if (!empty($arrayfields['customerorsupplier']['checked'])) +{ @@ -1406,3 +890 @@ - if ($type != '') { - print ''; - } + if ($type != '') print ''; @@ -1410 +892 @@ - print ''; + print ''; @@ -1413,3 +895,4 @@ -if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { - print ''; -} -if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); + print ''; +} +if (!empty($arrayfields['s2.nom']['checked'])) +{ + print ''; @@ -1439 +924 @@ -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -1441,20 +926,10 @@ -// Creation date -if (!empty($arrayfields['s.datec']['checked'])) { - print ''; -} -// Modification date -if (!empty($arrayfields['s.tms']['checked'])) { - print ''; +} +// Date modification +if (!empty($arrayfields['s.tms']['checked'])) +{ + print ''; -} -if (!empty($arrayfields['s.import_key']['checked'])) { +if (!empty($arrayfields['s.status']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['s.import_key']['checked'])) +{ @@ -1475,14 +952,7 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} - -print ''."\n"; - -$totalarray = array(); -$totalarray['nbfield'] = 0; - -// Fields title label -// -------------------------------------------------------------------- +print ''; + +print "\n"; + @@ -1490,137 +960,30 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.rowid']['checked'])) { - print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, ' data-key="id"', $sortfield, $sortorder, ''); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, ' data-key="ref"', $sortfield, $sortorder, ' '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.name_alias']['checked'])) { - print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.barcode']['checked'])) { - print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.code_client']['checked'])) { - print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.code_fournisseur']['checked'])) { - print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.code_compta']['checked'])) { - print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { - print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.address']['checked'])) { - print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['sales.representative']['checked'])) { - print_liste_field_titre($arrayfields['sales.representative']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.zip']['checked'])) { - print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.town']['checked'])) { - print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['state.nom']['checked'])) { - print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['region.nom']['checked'])) { - print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['typent.code']['checked'])) { - print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, "", $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['staff.code']['checked'])) { - print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.price_level']['checked'])) { - print_liste_field_titre($arrayfields['s.price_level']['label'], $_SERVER["PHP_SELF"], "s.price_level", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.email']['checked'])) { - print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.phone']['checked'])) { - print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.fax']['checked'])) { - print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.url']['checked'])) { - print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.siren']['checked'])) { - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.siret']['checked'])) { - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.ape']['checked'])) { - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.idprof4']['checked'])) { - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.idprof5']['checked'])) { - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[5], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.idprof6']['checked'])) { - print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[6], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.tva_intra']['checked'])) { - print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['customerorsupplier']['checked'])) { - print_liste_field_titre($arrayfields['customerorsupplier']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'center '); // type of customer - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { - print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.fk_stcomm']['checked'])) { - print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s2.nom']['checked'])) { - print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} +if (!empty($arrayfields['s.rowid']['checked'])) print_liste_field_titre($arrayfields['s.rowid']['label'], $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.name_alias']['checked'])) print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($arrayfields['s.barcode']['label'], $_SERVER["PHP_SELF"], "s.barcode", $param, '', '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER["PHP_SELF"], "s.code_client", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'], $_SERVER["PHP_SELF"], "region.nom", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['staff.code']['checked'])) print_liste_field_titre($arrayfields['staff.code']['label'], $_SERVER["PHP_SELF"], "staff.code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'], $_SERVER["PHP_SELF"], "s.phone", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'], $_SERVER["PHP_SELF"], "s.fax", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.url']['checked'])) print_liste_field_titre($arrayfields['s.url']['label'], $_SERVER["PHP_SELF"], "s.url", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"), $textprofid[1], 1, 0), $_SERVER["PHP_SELF"], "s.siren", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"), $textprofid[2], 1, 0), $_SERVER["PHP_SELF"], "s.siret", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"), $textprofid[3], 1, 0), $_SERVER["PHP_SELF"], "s.ape", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof4", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof5", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"), $textprofid[4], 1, 0), $_SERVER["PHP_SELF"], "s.idprof6", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'], $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder, 'nowrap '); +if (!empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer +if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "s.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'], $_SERVER["PHP_SELF"], "s.fk_stcomm", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s2.nom']['checked'])) print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER["PHP_SELF"], "s2.nom", "", $param, '', $sortfield, $sortorder, 'center '); @@ -1631 +994 @@ -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -1633,26 +996,8 @@ -if (!empty($arrayfields['s.datec']['checked'])) { - print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; // For the column action -} -if (!empty($arrayfields['s.tms']['checked'])) { - print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; // For the column action -} -if (!empty($arrayfields['s.status']['checked'])) { - print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; // For the column action -} -if (!empty($arrayfields['s.import_key']['checked'])) { - print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; // For the column action -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -print ''."\n"; - - -// Loop on record -// -------------------------------------------------------------------- +if (!empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($arrayfields['s.datec']['label'], $_SERVER["PHP_SELF"], "s.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($arrayfields['s.tms']['label'], $_SERVER["PHP_SELF"], "s.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['s.status']['checked'])) print_liste_field_titre($arrayfields['s.status']['label'], $_SERVER["PHP_SELF"], "s.status", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['s.import_key']['checked'])) print_liste_field_titre($arrayfields['s.import_key']['label'], $_SERVER["PHP_SELF"], "s.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "\n"; + + @@ -1660 +1004,0 @@ -$savnbfield = $totalarray['nbfield']; @@ -1662,3 +1006,2 @@ -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { +while ($i < min($num, $limit)) +{ @@ -1666,39 +1009,43 @@ - if (empty($obj)) { - break; // Should not happen - } - - $parameters = array('staticdata' => $obj); - // Note that $action and $object may have been modified by hook - // do companystatic fetch in hook if wanted or anything else - $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action); - if (empty($reshook)) { - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->name_alias = $obj->name_alias; - $companystatic->logo = $obj->logo; - $companystatic->barcode = $obj->barcode; - $companystatic->canvas = $obj->canvas; - $companystatic->client = $obj->client; - $companystatic->status = $obj->status; - $companystatic->email = $obj->email; - $companystatic->address = $obj->address; - $companystatic->zip = $obj->zip; - $companystatic->town = $obj->town; - $companystatic->fournisseur = $obj->fournisseur; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->tva_intra = $obj->tva_intra; - $companystatic->country_code = $obj->country_code; - - $companystatic->code_compta_client = $obj->code_compta; - $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; - - $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; - $companystatic->parent = $obj->fk_parent; - $companystatic->entity = $obj->entity; - } - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; + if (!empty($arrayfields['s.rowid']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.nom']['checked'])) + { + $savalias = $obj->name_alias; + if (!empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias = ''; + print ''; + else + { + print $companystatic->getNomUrl(1, '', 100, 0, 1); @@ -1712,6 +1057,149 @@ - } else { - // Show line of result - $j = 0; - print '\n"; + $companystatic->name_alias = $savalias; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.name_alias']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Barcode + if (!empty($arrayfields['s.barcode']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Customer code + if (!empty($arrayfields['s.code_client']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Supplier code + if (!empty($arrayfields['s.code_fournisseur']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Account customer code + if (!empty($arrayfields['s.code_compta']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Account supplier code + if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // State + if (!empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Region + if (!empty($arrayfields['region.nom']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Staff + if (!empty($arrayfields['staff.code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.email']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.phone']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.fax']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.url']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.siren']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.siret']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.ape']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.idprof4']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.idprof5']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.idprof6']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.tva_intra']['checked'])) + { + print "'; - if (!$i) { - $totalarray['nbfield']++; - } + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Type + if (!empty($arrayfields['customerorsupplier']['checked'])) + { + print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } + if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + if ($s) $s .= ", "; + $companystatic->name = $langs->trans("Prospect"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'prospect', 0, 1); @@ -1744,11 +1228,6 @@ - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if ($contextpage == 'poslist') { - print dol_escape_htmltag($companystatic->name); - } else { - print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) + { + if ($s) $s .= ", "; + $companystatic->name = $langs->trans("Supplier"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'supplier', 0, 1); @@ -1756,7 +1235,25 @@ - if (!empty($arrayfields['s.name_alias']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } + print $s; + print ''; + if (!$i) $totalarray['nbfield']++; + } + + if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) + { + // Prospect level + print '"; + if (!$i) $totalarray['nbfield']++; + } + + if (!empty($arrayfields['s.fk_stcomm']['checked'])) + { + // Prospect status + print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Customer code - if (!empty($arrayfields['s.code_client']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Supplier code - if (!empty($arrayfields['s.code_fournisseur']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Account customer code - if (!empty($arrayfields['s.code_compta']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Account supplier code - if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Address - if (!empty($arrayfields['s.address']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Sales Representative - if (!empty($arrayfields['sales.representative']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Region - if (!empty($arrayfields['region.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - if (!isset($typenArray) || !is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - $labeltypeofcompany= empty($typenArray[$obj->typent_code]) ? '' : $typenArray[$obj->typent_code]; - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Multiprice level - if (!empty($arrayfields['s.price_level']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Staff - if (!empty($arrayfields['staff.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.email']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.phone']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.fax']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.url']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.siren']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.siret']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.ape']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.idprof4']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.idprof5']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['s.idprof6']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // VAT - if (!empty($arrayfields['s.tva_intra']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Nature - if (!empty($arrayfields['customerorsupplier']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Prospect level - if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Prospect status - if (!empty($arrayfields['s.fk_stcomm']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['s.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['s.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['s.status']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Import key - if (!empty($arrayfields['s.import_key']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column (Show the massaction button only when this page is not opend from the Extended POS) - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - print ''."\n"; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) + { + print '"; + if (!$i) $totalarray['nbfield']++; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['s.datec']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['s.tms']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Status + if (!empty($arrayfields['s.status']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['s.import_key']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''."\n"; @@ -2094,14 +1326,0 @@ -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - -// If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; -} - @@ -2111 +1330 @@ -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook @@ -2114,7 +1333,4 @@ -print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; +if (!empty($arrayfields['s.rowid']['checked'])) +{ + print ''; @@ -1233,5 +711,4 @@ -if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!empty($search_nom_only) && empty($search_nom)) { - $search_nom = $search_nom_only; - } +if (!empty($arrayfields['s.nom']['checked'])) +{ + print ''; + if (!empty($search_nom_only) && empty($search_nom)) $search_nom = $search_nom_only; @@ -1241 +718,2 @@ -if (!empty($arrayfields['s.name_alias']['checked'])) { +if (!empty($arrayfields['s.name_alias']['checked'])) +{ @@ -1247 +725,2 @@ -if (!empty($arrayfields['s.barcode']['checked'])) { +if (!empty($arrayfields['s.barcode']['checked'])) +{ @@ -1253 +732,2 @@ -if (!empty($arrayfields['s.code_client']['checked'])) { +if (!empty($arrayfields['s.code_client']['checked'])) +{ @@ -1259 +739,2 @@ -if (!empty($arrayfields['s.code_fournisseur']['checked'])) { +if (!empty($arrayfields['s.code_fournisseur']['checked'])) +{ @@ -1265 +746,2 @@ -if (!empty($arrayfields['s.code_compta']['checked'])) { +if (!empty($arrayfields['s.code_compta']['checked'])) +{ @@ -1271 +753,2 @@ -if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { +if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) +{ @@ -1276,9 +759,5 @@ -// Address -if (!empty($arrayfields['s.address']['checked'])) { - print ''; - print ''; - print ''; +// Town +if (!empty($arrayfields['s.town']['checked'])) +{ + print ''; + print ''; @@ -1288 +767,2 @@ -if (!empty($arrayfields['s.zip']['checked'])) { +if (!empty($arrayfields['s.zip']['checked'])) +{ @@ -1293,6 +772,0 @@ -// Town -if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print ''; - print ''; - print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); @@ -1331 +802,2 @@ -if (!empty($arrayfields['staff.code']['checked'])) { +if (!empty($arrayfields['staff.code']['checked'])) +{ @@ -1333,4 +805,5 @@ - print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1); - print ''; - print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); +if (!empty($arrayfields['s.fk_prospectlevel']['checked'])) +{ + print ''; + print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); @@ -1419 +902,2 @@ -if (!empty($arrayfields['s.fk_stcomm']['checked'])) { +if (!empty($arrayfields['s.fk_stcomm']['checked'])) +{ @@ -1422 +906,2 @@ - foreach ($prospectstatic->cacheprospectstatus as $key => $val) { + foreach ($prospectstatic->cacheprospectstatus as $key => $val) + { @@ -1425,8 +910,8 @@ - //print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1); - print $form->multiselectarray('search_stcomm', $arraystcomm, $search_stcomm, 0, 0, 'width100', 0, 0, '', '', '', 2); - print ''; - print ''; - print ''; + print ''; + print ''; - print '
'; - print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print '
'; - print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1, 'search_date_modif_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1, 'search_date_modif_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; +// Date creation +if (!empty($arrayfields['s.datec']['checked'])) +{ + print '
'; + print ''; @@ -1464,6 +939,8 @@ -if (!empty($arrayfields['s.status']['checked'])) { - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); - print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1); + print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'; - print '
'; + + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->name_alias; + $companystatic->logo = $obj->logo; + $companystatic->canvas = $obj->canvas; + $companystatic->client = $obj->client; + $companystatic->status = $obj->status; + $companystatic->email = $obj->email; + $companystatic->fournisseur = $obj->fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->tva_intra = $obj->tva_intra; + $companystatic->country_code = $obj->country_code; + + $companystatic->code_compta_client = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; + + $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; + $companystatic->fk_parent = $obj->fk_parent; + $companystatic->entity = $obj->entity; + + print '
'; + print $obj->rowid; + print "'; + if ($contextpage == 'poslist') + { + print $obj->name; @@ -1706,5 +1053,3 @@ - // Output Kanban - print $companystatic->getKanbanView('', array('selected' => in_array($obj->rowid, $arrayofselected))); - if ($i == ($imaxinloop - 1)) { - print ''; - print '
'; + print $companystatic->name_alias; + print "'.$obj->barcode.''.$obj->code_client.''.$obj->code_fournisseur.''.$obj->code_compta.''.$obj->code_compta_fournisseur.'".$obj->town."".$obj->zip."".$obj->state_name."".$obj->region_name."'; + $labelcountry = ($obj->country_code && ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)) ? $langs->trans("Country".$obj->country_code) : $obj->country_label; + print $labelcountry; + print ''; + if (!is_array($typenArray) || count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; + if (!is_array($staffArray) || count($staffArray) == 0) $staffArray = $formcompany->effectif_array(1); + print $staffArray[$obj->staff_code]; + print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."".dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL')."".dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid, 'AC_TEL')."".$obj->url."".$obj->idprof1."".$obj->idprof2."".$obj->idprof3."".$obj->idprof4."".$obj->idprof5."".$obj->idprof6.""; + print $obj->tva_intra; + if ($obj->tva_intra && !isValidVATID($companystatic)) + { + print img_warning("BadVATNumber", '', ''); @@ -1719,16 +1207,13 @@ - print '>'; - - // Action column (Show the massaction button only when this page is not opend from the Extended POS) - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; + $s = ''; + if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $companystatic->name = $langs->trans("Customer"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'customer', 0, 1); @@ -1736,7 +1221,6 @@ - if (!empty($arrayfields['s.rowid']['checked'])) { - print ''; - print $obj->rowid; - print "'; - print dol_escape_htmltag($companystatic->name_alias); - print "'; + print $companystatic->getLibProspLevel(); + print "
'; + print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']); + print '
-
'; + foreach ($prospectstatic->cacheprospectstatus as $key => $val) + { + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label']; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code']).''; @@ -1764,327 +1261,63 @@ - // Barcode - if (!empty($arrayfields['s.barcode']['checked'])) { - print '
'.dol_escape_htmltag($companystatic->barcode).''.dol_escape_htmltag($companystatic->code_client).''.dol_escape_htmltag($companystatic->code_fournisseur).''.dol_escape_htmltag($companystatic->code_compta_client).''.dol_escape_htmltag($companystatic->code_compta_fournisseur).''.dol_escape_htmltag($companystatic->address).''; - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; - } - } - } else { - print ' '; - } - print '".dol_escape_htmltag($companystatic->zip)."'.dol_escape_htmltag($companystatic->town)."".dol_escape_htmltag($obj->state_name)."".dol_escape_htmltag($obj->region_name)."'; - $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label; - print $labelcountry; - print ''; - print dol_escape_htmltag($labeltypeofcompany); - print ''.$obj->price_level."'; - if (!empty($obj->staff_code)) { - if (empty($conf->cache['staffArray'])) { - $conf->cache['staffArray'] = $formcompany->effectif_array(1); - } - print $conf->cache['staffArray'][$obj->staff_code]; - } - print ''.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."'.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."'.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."".dol_print_url($obj->url, '', '', 1)."".$obj->idprof1."".$obj->idprof2."".$obj->idprof3."".$obj->idprof4."".$obj->idprof5."".$obj->idprof6."'; - if ($companystatic->tva_intra && !isValidVATID($companystatic)) { - print img_warning("BadVATNumber", '', 'pictofixedwidth'); - } - print $companystatic->tva_intra; - print "'; - print $companystatic->getTypeUrl(1); - print ''; - print $companystatic->getLibProspLevel(); - print "'; - - $prospectid = $obj->rowid; - $statusprospect = $obj->stcomm_id; - - $formcompany->selectProspectStatus('status_prospect', $prospectstatic, $statusprospect, $prospectid); - - print ''; - if ($companystatic->parent > 0) { - $companyparent->fetch($companystatic->parent); - print $companyparent->getNomUrl(1); - } - print "'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$companystatic->getLibStatut(5).''; - print dol_escape_htmltag($obj->import_key); - print "'; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'; + if ($companystatic->fk_parent > 0) + { + $companyparent->fetch($companystatic->fk_parent); + print $companyparent->getNomUrl(1); + } + print "'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$companystatic->getLibStatut(5).''; + print $obj->import_key; + print "'; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; -print '
'."\n"; - -// Line that calls the select_status function by passing it js as the 5th parameter in order to activate the js script -$formcompany->selectProspectStatus('status_prospect', $prospectstatic, null, null, "js"); - -print ''."\n"; +print ""; +print "
"; + +print ''; --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_note.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_note.php @@ -29,2 +28,0 @@ - -// Load Dolibarr environment @@ -33,0 +32 @@ +$action = GETPOST('action', 'aZ09'); @@ -35 +33,0 @@ -// Load translation files required by the page @@ -37,0 +36,4 @@ +// Security check +$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); +if ($user->socid) $id = $user->socid; +$result = restrictedArea($user, 'societe', $id, '&societe'); @@ -39,3 +41,2 @@ -// Get parameters -$id = GETPOST('id') ? GETPOST('id', 'int') : GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); +$object = new Societe($db); +if ($id > 0) $object->fetch($id); @@ -43,9 +44 @@ - -// Initialize objects -$object = new Societe($db); -if ($id > 0) { - $object->fetch($id); -} - -// Permissions -$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php @@ -55,8 +47,0 @@ - -// Security check -if ($user->socid > 0) { - unset($action); - $socid = $user->socid; -} - -$result = restrictedArea($user, 'societe', $object->id, '&societe'); @@ -69,8 +54 @@ -$parameters = array(); -$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)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -86,3 +64 @@ -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name.' - '.$langs->trans("Notes"); -} +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notes"); @@ -92,7 +68,6 @@ -if ($object->id > 0) { - /* - * Affichage onglets - */ - if (isModEnabled('notification')) { - $langs->load("mails"); - } +if ($object->id > 0) +{ + /* + * Affichage onglets + */ + if (!empty($conf->notification->enabled)) $langs->load("mails"); @@ -100 +75 @@ - $head = societe_prepare_head($object); + $head = societe_prepare_head($object); @@ -102 +77 @@ - print dol_get_fiche_head($head, 'note', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'note', $langs->trans("ThirdParty"), -1, 'company'); @@ -104 +79 @@ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; @@ -106 +81 @@ - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); @@ -108,3 +83,3 @@ - $cssclass = 'titlefield'; - //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; - //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; + $cssclass = 'titlefield'; + //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; + //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; @@ -112 +87 @@ - print '
'; + print '
'; @@ -114,2 +89,2 @@ - print '
'; - print ''; + print '
'; + print '
'; @@ -117,4 +92,4 @@ - // Type Prospect/Customer/Supplier - print ''; + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } @@ -122,3 +97,8 @@ - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''; - } + if ($object->client) + { + print ''; + } @@ -126,10 +106,8 @@ - if ($object->client) { - print ''; - } + if ($object->fournisseur) + { + print ''; + } @@ -137,10 +115 @@ - if ($object->fournisseur) { - print ''; - } + print "
'.$langs->trans('NatureOfThirdParty').''; - print $object->getTypeUrl(1); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$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('CustomerCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - 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('SupplierCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print '
"; @@ -148 +117 @@ - print ""; + print '
'; @@ -150 +119 @@ - print '
'; + //print '
'; @@ -152 +121,2 @@ - //print '
'; + //print '
'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; @@ -154,5 +124,4 @@ - //print '
'; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - - print dol_get_fiche_end(); -} else { + dol_fiche_end(); +} +else +{ --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_paymentmodes.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_paymentmodes.php @@ -2,9 +2,8 @@ -/* Copyright (C) 2002-2004 Rodolphe Quiedeville - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2022 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Peter Fontaine - * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2023 Thibault FOUCART - * Copyright (C) 2021 Alexandre Spangaro +/* Copyright (C) 2002-2004 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Peter Fontaine + * Copyright (C) 2015-2016 Marcos García + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018 ptibogxiv @@ -32,2 +30,0 @@ - -// Load Dolibarr environment @@ -45,2 +41,0 @@ - -// Load translation files required by the page @@ -50,4 +45,4 @@ -// Get parameters -$action = GETPOST("action", 'alpha', 3); -$cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage'); +// Security check +$socid = GETPOST("socid", "int"); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'societe', '', ''); @@ -58,8 +53,3 @@ - -// Security check -$socid = GETPOST("socid", "int"); -if ($user->socid) { - $socid = $user->socid; -} - -// Initialize objects +$action = GETPOST("action", 'alpha', 3); +$cancel = GETPOST('cancel', 'alpha'); + @@ -81,13 +71,3 @@ -// Permissions -$permissiontoread = $user->hasRight('societe', 'lire'); -$permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php - -$permissiontoaddupdatepaymentinformation = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write))); - - -// Check permission on company -$result = restrictedArea($user, 'societe', '', ''); - - -// Init Stripe objects -if (isModEnabled('stripe')) { + +if (!empty($conf->stripe->enabled)) +{ @@ -96 +76,2 @@ - if (getDolGlobalString('STRIPE_LIVE') && !GETPOST('forcesandbox', 'alpha')) { + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) + { @@ -110 +90,0 @@ -$error = 0; @@ -117 +97,2 @@ -if ($cancel) { +if ($cancel) +{ @@ -121,2 +102 @@ -$morehtmlright = ''; -$parameters = array('id'=>$socid); +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); @@ -124,6 +104,6 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - if ($cancel) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($cancel) + { @@ -131 +111,2 @@ - if (!empty($backtopage)) { + if (!empty($backtopage)) + { @@ -137,9 +118,7 @@ - if ($action == 'update') { - // Update the bank account - if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) { - if (!GETPOST('label', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - } - if (!GETPOST('bank', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - } + if ($action == 'update') + { + // Modification + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) + { + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); @@ -149,3 +128,4 @@ - $companybankaccount->fetch($id); - if ($companybankaccount->needIBAN() == 1) { - if (!GETPOST('iban')) { + if ($companybankaccount->needIBAN() == 1) + { + if (!GETPOST('iban')) + { @@ -156 +136,2 @@ - if (!GETPOST('bic')) { + if (!GETPOST('bic')) + { @@ -163,3 +144,3 @@ - if (!$error) { - $companybankaccount->oldcopy = dol_clone($companybankaccount); - + $companybankaccount->fetch($id); + if (!$error) + { @@ -184 +165,2 @@ - if (empty($companybankaccount->rum)) { + if (empty($companybankaccount->rum)) + { @@ -187,6 +169,4 @@ - - if (GETPOST('stripe_card_ref', 'alpha') && GETPOST('stripe_card_ref', 'alpha') != $companypaymentmode->stripe_card_ref) { - // If we set a stripe value that is different than previous one, we also set the stripe account - $companypaymentmode->stripe_account = $stripecu.'@'.$site_account; - } - $companybankaccount->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); + if (empty($companybankaccount->date_rum)) + { + $companybankaccount->date_rum = dol_now(); + } @@ -195,2 +175,2 @@ - if ($result <= 0) { - // Display error message and get back to edit mode + if (!$result) + { @@ -198,2 +178,3 @@ - $action = 'edit'; - } else { + } + else + { @@ -201 +182,2 @@ - if ($companybankaccount->default_rib) { + if ($companybankaccount->default_rib) + { @@ -203,6 +184,0 @@ - } - - if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) { - if ($companybankaccount->oldcopy->iban != $companybankaccount->iban) { - // TODO If we modified the iban, we must also update the pm_ on Stripe side, or break the link completely ? - } @@ -218,9 +194,7 @@ - if ($action == 'updatecard') { - // Update credit card - if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) { - if (!GETPOST('label', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - } - if (!GETPOST('proprio', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - } + if ($action == 'updatecard') + { + // Modification + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) + { + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); @@ -228,3 +202 @@ - if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - } + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); @@ -237,3 +209,2 @@ - if (!$error) { - $companybankaccount->oldcopy = dol_clone($companybankaccount); - + if (!$error) + { @@ -259 +230,2 @@ - if (!$result) { + if (!$result) + { @@ -261 +233,3 @@ - } else { + } + else + { @@ -263 +237,2 @@ - if ($companypaymentmode->default_rib) { + if ($companypaymentmode->default_rib) + { @@ -265,6 +239,0 @@ - } - - if ($companypaymentmode->oldcopy->stripe_card_ref != $companypaymentmode->stripe_card_ref) { - if ($companybankaccount->oldcopy->number != $companybankaccount->number) { - // TODO If we modified the card, we must also update the pm_ on Stripe side, or break the link completely ? - } @@ -280,2 +249,2 @@ - // Add bank account - if ($action == 'add') { + if ($action == 'add') + { @@ -284,2 +253,4 @@ - if (!GETPOST('label', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) + { + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); @@ -290 +261,2 @@ - if (!$error) { + if (!$error) + { @@ -295,2 +266,0 @@ - - $companybankaccount->fetch_thirdparty(); @@ -311 +281 @@ - $companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha'); + $companybankaccount->frstrecur = GETPOST('frstrecur'); @@ -313 +283 @@ - $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth', 'int'), GETPOST('date_rumday', 'int'), GETPOST('date_rumyear', 'int')); + $companybankaccount->date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); @@ -315,7 +285 @@ - $companybankaccount->status = 1; - - $companybankaccount->bank = trim($companybankaccount->bank); - if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) { - $companybankaccount->bank = $langs->trans("Bank").' '.$companybankaccount->thirdparty->name; - } - $companybankaccount->bic = str_replace(' ', '', $companybankaccount->bic); + $companybankaccount->status = 1; @@ -326,2 +290,4 @@ - if ($companybankaccount->needIBAN() == 1) { - if (!GETPOST('iban')) { + if ($companybankaccount->needIBAN() == 1) + { + if (!GETPOST('iban')) + { @@ -332 +298,2 @@ - if (!GETPOST('bic')) { + if (!GETPOST('bic')) + { @@ -339 +306,2 @@ - if (!$error) { + if (!$error) + { @@ -341 +309,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -347 +316,2 @@ - if (empty($companybankaccount->rum)) { + if (empty($companybankaccount->rum)) + { @@ -349,4 +319,6 @@ - } - } - - if (!$error) { + $companybankaccount->date_rum = dol_now(); + } + } + + if (!$error) + { @@ -354 +326,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -361 +334,2 @@ - if (!$error) { + if (!$error) + { @@ -367 +341,3 @@ - } else { + } + else + { @@ -373,2 +349,2 @@ - // Add credit card - if ($action == 'addcard') { + if ($action == 'addcard') + { @@ -377,7 +353,4 @@ - if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) { - if (!GETPOST('label', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - } - if (!GETPOST('proprio', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); - } + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha')) + { + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); @@ -385,3 +358 @@ - if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); - } + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); @@ -393 +364,2 @@ - if (!$error) { + if (!$error) + { @@ -420 +392,2 @@ - if (!$error) { + if (!$error) + { @@ -422 +395,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -429 +403,2 @@ - if (!$error) { + if (!$error) + { @@ -435 +410,3 @@ - } else { + } + else + { @@ -441 +418,2 @@ - if ($action == 'setasbankdefault' && GETPOST('ribid', 'int') > 0) { + if ($action == 'setasbankdefault' && GETPOST('ribid', 'int') > 0) + { @@ -444 +422,2 @@ - if ($res) { + if ($res) + { @@ -448 +427,3 @@ - } else { + } + else + { @@ -453,2 +434,2 @@ - if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') { - // Delete the credi card + if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') + { @@ -456,2 +437,2 @@ - if ($companypaymentmode->fetch($ribid ? $ribid : $id)) { - // TODO This is currently done at bottom of page instead of asking confirm + if ($companypaymentmode->fetch($ribid ? $ribid : $id)) + { @@ -468 +449,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -470 +451,0 @@ - @@ -473 +454,3 @@ - } else { + } + else + { @@ -476 +459,3 @@ - } else { + } + else + { @@ -480,2 +465,2 @@ - if ($action == 'confirm_deletebank' && GETPOST('confirm', 'alpha') == 'yes') { - // Delete the bank account + if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes') + { @@ -483,11 +468,2 @@ - if ($companybankaccount->fetch($ribid ? $ribid : $id) > 0) { - // TODO This is currently done at bottom of page instead of asking confirm - /*if ($companypaymentmode->stripe_card_ref && preg_match('/pm_/', $companypaymentmode->stripe_card_ref)) - { - $payment_method = \Stripe\PaymentMethod::retrieve($companypaymentmode->stripe_card_ref); - if ($payment_method) - { - $payment_method->detach(); - } - }*/ - + if ($companybankaccount->fetch($ribid ? $ribid : $id)) + { @@ -495,2 +471,2 @@ - - if ($result > 0) { + if ($result > 0) + { @@ -498 +473,0 @@ - @@ -501 +476,3 @@ - } else { + } + else + { @@ -504 +481,3 @@ - } else { + } + else + { @@ -512 +491,2 @@ - if ($action == 'builddocrib') { + if ($action == 'builddocrib') + { @@ -523,0 +504 @@ + $permissiontoadd = $user->rights->societe->creer; @@ -529,3 +510,6 @@ - if (isModEnabled('stripe') && class_exists('Stripe')) { - if ($action == 'synccustomertostripe' || $action == 'synccustomertostripetest') { - if ($object->client == 0) { + if (!empty($conf->stripe->enabled) && class_exists('Stripe')) + { + if ($action == 'synccustomertostripe') + { + if ($object->client == 0) + { @@ -534,12 +518,3 @@ - } else { - if ($action == 'synccustomertostripe') { - $tmpservicestatus = 1; - $tmpservice = 'StripeLive'; - } else { - $tmpservicestatus = 0; - $tmpservice = 'StripeTest'; - } - - $stripe = new Stripe($db); - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) - + } + else + { @@ -547,3 +522,3 @@ - $tmpcu = $stripe->customerStripe($object, $tmpstripeacc, $tmpservicestatus, 1); - - if (empty($tmpcu)) { + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); + if (!$cu) + { @@ -552,9 +527,9 @@ - } else { - if ($tmpservicestatus == $servicestatus) { - $stripecu = $tmpcu->id; - } - } - } - } - if ($action == 'synccardtostripe') { - // Create the credit card on current Stripe env + } + else + { + $stripecu = $cu->id; + } + } + } + if ($action == 'synccardtostripe') + { @@ -564 +539,2 @@ - if ($companypaymentmode->type != 'card') { + if ($companypaymentmode->type != 'card') + { @@ -567 +543,3 @@ - } else { + } + else + { @@ -570 +548,2 @@ - if (!$cu) { + if (!$cu) + { @@ -575,2 +554,3 @@ - if (!$error) { - // Creation of Stripe card + update of llx_societe_rib + if (!$error) + { + // Creation of Stripe card + update of societe_account @@ -580 +560,2 @@ - if (!$card) { + if (!$card) + { @@ -587,33 +568,3 @@ - if ($action == 'syncsepatostripe') { - // Create the bank account on current Stripe env - $companypaymentmode = new CompanyPaymentMode($db); // Get record in llx_societe_rib - $companypaymentmode->fetch($id); - - if ($companypaymentmode->type != 'ban') { - $error++; - $langs->load("errors"); - setEventMessages('ThisPaymentModeIsNotABan', null, 'errors'); - } else { - // Get the Stripe customer - $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - // print json_encode($cu); - if (empty($cu)) { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorStripeCustomerNotFoundCreateFirst"), null, 'errors'); - } - if (!$error) { - // Creation of Stripe SEPA + update of llx_societe_rib - $card = $stripe->sepaStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); - if (!$card) { - $error++; - setEventMessages($stripe->error, $stripe->errors, 'errors'); - } else { - setEventMessages("", array("Bank Account on Stripe", "BAN is now linked to the Stripe customer account !")); - } - } - } - } - - // Set the customer Stripe account (for Live or Test env) - if ($action == 'setkey_account' || $action == 'setkey_accounttest') { + + if ($action == 'setkey_account') + { @@ -622,16 +573 @@ - $tmpservice = 'StripeTest'; - $tmpservicestatus = 0; - if ($action == 'setkey_account') { - $tmpservice = 'StripeLive'; - $tmpservicestatus = 1; - } - - // Force to use the correct API key - global $stripearrayofkeysbyenv; - $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus]['publishable_key']; - - if ($action == 'setkey_account') { - $newcu = GETPOST('key_account', 'alpha'); - } else { - $newcu = GETPOST('key_accounttest', 'alpha'); - } + $newcu = GETPOST('key_account', 'alpha'); @@ -641,6 +577,6 @@ - if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".$object->id." AND status = ".((int) $tmpservicestatus)." AND entity = ".$conf->entity; - } else { - $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $tmpservicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } + if (empty($newcu)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$site_account."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + } else { + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_account"; + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$site_account."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } @@ -651 +587,2 @@ - if (empty($num)) { + if (empty($num)) + { @@ -659 +596 @@ - $societeaccount->site_account = $tmpsite_account; + $societeaccount->site_account = $site_account; @@ -661 +598,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -666,2 +604,2 @@ - $sql .= " SET key_account = '".$db->escape($newcu)."', site_account = '".$db->escape($tmpsite_account)."'"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".((int) $object->id)." AND status = ".((int) $tmpservicestatus)." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."', site_account = '".$site_account."'"; + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$site_account."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! @@ -671,8 +609,5 @@ - //var_dump($sql); - //var_dump($newcu); - //var_dump($num); exit; - - if (!$error) { - if ($tmpservicestatus == $servicestatus) { - $stripecu = $newcu; - } + //var_dump($sql); var_dump($newcu); var_dump($num); exit; + + if (!$error) + { + $stripecu = $newcu; @@ -680 +615,3 @@ - } else { + } + else + { @@ -685,2 +622,2 @@ - // Set the supplier Stripe account (for Live or Test env) - if ($action == 'setkey_account_supplier' || $action == 'setkey_account_suppliertest') { + if ($action == 'setkey_account_supplier') + { @@ -689,16 +626 @@ - $tmpservice = 'StripeTest'; - $tmpservicestatus = 0; - if ($action == 'setkey_account_supplier') { - $tmpservice = 'StripeLive'; - $tmpservicestatus = 1; - } - - // Force to use the correct API key - global $stripearrayofkeysbyenv; - $tmpsite_account = $stripearrayofkeysbyenv[$tmpservicestatus]['publishable_key']; - - if ($action == 'setkey_account_supplier') { - $newsup = GETPOST('key_account_supplier', 'alpha'); - } else { - $newsup = GETPOST('key_account_suppliertest', 'alpha'); - } + $newsup = GETPOST('key_account_supplier', 'alpha'); @@ -708,15 +630,15 @@ - if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity; - // TODO Add site and site_account on oauth_token table - //$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($service)."' AND entity = ".$conf->entity; - } else { - try { - $stripesup = \Stripe\Account::retrieve($newsup); - $tokenstring['stripe_user_id'] = $stripesup->id; - $tokenstring['type'] = $stripesup->type; - $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; - $sql .= " SET tokenstring = '".$db->escape(json_encode($tokenstring))."'"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($tmpsite_account)."') AND fk_soc = ".((int) $object->id)." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - // TODO Add site and site_account on oauth_token table - $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$db->escape($tmpservice)."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } catch (Exception $e) { + if (empty($newsup)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; + // TODO Add site and site_account on oauth_token table + //$sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$site_account."') AND fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; + } else { + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + $tokenstring['stripe_user_id'] = $stripesup->id; + $tokenstring['type'] = $stripesup->type; + $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; + $sql .= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; + $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$site_account."') AND fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + // TODO Add site and site_account on oauth_token table + $sql .= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } catch (Exception $e) { @@ -730,9 +652,10 @@ - if (empty($num) && !empty($newsup)) { - try { - $stripesup = \Stripe\Account::retrieve($newsup); - $tokenstring['stripe_user_id'] = $stripesup->id; - $tokenstring['type'] = $stripesup->type; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; - $sql .= " VALUES ('".$db->escape($tmpservice)."', ".((int) $object->id).", ".((int) $conf->entity).", '".$db->escape(json_encode($tokenstring))."')"; - // TODO Add site and site_account on oauth_token table - } catch (Exception $e) { + if (empty($num) && !empty($newsup)) + { + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + $tokenstring['stripe_user_id'] = $stripesup->id; + $tokenstring['type'] = $stripesup->type; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; + $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; + // TODO Add site and site_account on oauth_token table + } catch (Exception $e) { @@ -745,4 +668,3 @@ - if (!$error) { - if ($tmpservicestatus == $servicestatus) { - $stripesupplieracc = $newsup; - } + if (!$error) + { + $stripesupplieracc = $newsup; @@ -750 +672,3 @@ - } else { + } + else + { @@ -755 +679,2 @@ - if ($action == 'setlocalassourcedefault') { // Set as default when payment mode defined locally (and may be also remotely) + if ($action == 'setlocalassourcedefault') // Set as default when payment mode defined locally (and may be also remotely) + { @@ -762 +687,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -766 +693,3 @@ - } elseif ($action == 'setassourcedefault') { // Set as default when payment mode defined remotely only + } + elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only + { @@ -769 +698,2 @@ - if (preg_match('/pm_|src_/', $source)) { + if (preg_match('/pm_/', $source)) + { @@ -771 +701,3 @@ - } else { + } + else + { @@ -779 +711,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -783,2 +717,3 @@ - } elseif ($action == 'deletecard' && $source) { - // Delete the credit card on Stripe side + } + elseif ($action == 'deletecard' && $source) + { @@ -786,11 +721,15 @@ - if (preg_match('/pm_/', $source)) { - $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); - if ($payment_method) { - $payment_method->detach(); - } - } else { - $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - $card = $cu->sources->retrieve("$source"); - if ($card) { - // $card->detach(); Does not work with card_, only with src_ - if (method_exists($card, 'detach')) { + if (preg_match('/pm_/', $source)) + { + $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); + if ($payment_method) + { + $payment_method->detach(); + } + } + else + { + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); + $card = $cu->sources->retrieve("$source"); + if ($card) { + // $card->detach(); Does not work with card_, only with src_ + if (method_exists($card, 'detach')) { @@ -798,4 +736,0 @@ - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib as sr "; - $sql .= " SET stripe_card_ref = null"; - $sql .= " WHERE sr.stripe_card_ref = '".$db->escape($source)."'"; - $resql = $db->query($sql); @@ -805 +740 @@ - } + } @@ -811,37 +746,3 @@ - } catch (Exception $e) { - $error++; - setEventMessages($e->getMessage(), null, 'errors'); - } - } elseif ($action == 'deletebank' && $source) { - // Delete the bank account on Stripe side - try { - if (preg_match('/pm_/', $source)) { - $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); - if ($payment_method) { - $payment_method->detach(); - } - } else { - $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); - $card = $cu->sources->retrieve("$source"); - if ($card) { - // $card->detach(); Does not work with card_, only with src_ - if (method_exists($card, 'detach')) { - $card->detach(); - $sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib as sr "; - $sql .= " SET stripe_card_ref = null"; - $sql .= " WHERE sr.stripe_card_ref = '".$db->escape($source)."'"; - $resql = $db->query($sql); - } else { - $card->delete(); - } - } - } - - $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; - if (GETPOST('page_y', 'int')) { - $url .= '&page_y='.GETPOST('page_y', 'int'); - } - - header('Location: '.$url); - exit; - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -865,7 +766 @@ -$title = $langs->trans("ThirdParty"); -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name." - ".$langs->trans('PaymentInformation'); -} -$help_url = ''; - -llxHeader('', $title, $help_url); +llxHeader(); @@ -876 +771 @@ -/*if (isModEnabled('paypal') && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' +/*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' @@ -880 +775,2 @@ -if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) { +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) +{ @@ -885 +781,2 @@ -if (!$id) { +if (!$id) +{ @@ -888 +785,3 @@ -} else { +} +else +{ @@ -892,5 +791,4 @@ -if (empty($companybankaccount->socid)) { - $companybankaccount->socid = $object->id; -} - -if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoaddupdatepaymentinformation) { +if (empty($companybankaccount->socid)) $companybankaccount->socid = $object->id; + +if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) +{ @@ -900,3 +798 @@ - if ($action == 'editcard') { - $actionforadd = 'updatecard'; - } + if ($action == 'editcard') $actionforadd = 'updatecard'; @@ -906 +802,2 @@ -if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoaddupdatepaymentinformation) { +if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) +{ @@ -910,3 +807 @@ - if ($action == 'createcard') { - $actionforadd = 'addcard'; - } + if ($action == 'createcard') $actionforadd = 'addcard'; @@ -918,2 +813,3 @@ -if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard') { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); +if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard') +{ + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); @@ -922,2 +818,3 @@ - if ($action == 'deletebank') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_deletebank", '', 0, 1); + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); @@ -926 +823,2 @@ - if ($action == 'deletecard') { + if ($action == 'deletecard') + { @@ -932,0 +831,8 @@ + + + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; + } + + //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); @@ -939,10 +845,2 @@ - // Type Prospect/Customer/Supplier - print ''.$langs->trans('NatureOfThirdParty').''; - print $object->getTypeUrl(1); - print ''; - - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; - } - - if ($object->client) { + if ($object->client) + { @@ -951,5 +849,2 @@ - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -957 +852 @@ - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; @@ -959,3 +854 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -966,22 +859,8 @@ - if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { - $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); - } - if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { - $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); - } - if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { - $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); - } - if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { - $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); - } - - if (isModEnabled('stripe')) { - // Force to use the correct API key - global $stripearrayofkeysbyenv; - - $tmpservice = 0; - $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) - $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) - + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); + + if (!empty($conf->stripe->enabled)) + { + $permissiontowrite = $user->rights->societe->creer; @@ -990 +869 @@ - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); @@ -992,8 +871,11 @@ - print $form->editfieldval($langs->trans("StripeCustomerId").' (Test)', 'key_accounttest', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); - if ($tmpstripecu && $action != 'editkey_accounttest') { - $connect = ''; - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } - $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$tmpstripecu; - print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$tmpsite_account, 'globe').''; + print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); + if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') + { + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; + if ($servicestatus) + { + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; + } + print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$site_account, 'globe').''; @@ -1002,31 +884,2 @@ - if (empty($tmpstripecu)) { - print '
'; - print ''; - print ''; - print ''; - print img_picto($langs->trans("CreateCustomerOnStripe"), 'stripe'); - print ''; - print '
'; - } - print ''; - - $tmpservice = 1; - $tmpsite_account = $stripearrayofkeysbyenv[$tmpservice]['publishable_key']; - $tmpstripeacc = $stripe->getStripeAccount($tmpservice); // Get Stripe OAuth connect account (no remote access to Stripe here) - $tmpstripecu = $stripe->getStripeCustomerAccount($object->id, $tmpservice, $tmpsite_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) - - // Stripe customer key 'cu_....' stored into llx_societe_account - print ''; - print $form->editfieldkey($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); - print ''; - print $form->editfieldval($langs->trans("StripeCustomerId").' (Live)', 'key_account', $tmpstripecu, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); - if ($tmpstripecu && $action != 'editkey_account') { - $connect = ''; - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } - $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$tmpstripecu; - print ' '.img_picto($langs->trans('ShowInStripe').' - Publishable key = '.$tmpsite_account, 'globe').''; - } - print ''; - if (empty($tmpstripecu)) { + if (empty($stripecu)) + { @@ -1037,2 +890 @@ - print img_picto($langs->trans("CreateCustomerOnStripe"), 'stripe'); - print ''; + print ''; @@ -1043,3 +895,4 @@ - } - - if ($object->fournisseur) { + } + + if ($object->fournisseur) + { @@ -1048,5 +901,2 @@ - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -1054 +904 @@ - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".((int) $socid); + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; @@ -1056,3 +906 @@ - if (!$resql) { - dol_print_error($db); - } + if (!$resql) dol_print_error($db); @@ -1062,16 +910,9 @@ - if (isModEnabled('propal') && $user->hasRight('propal', 'lire')) { - $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); - } - if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { - $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); - } - if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { - $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); - } - if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { - $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); - } - } - - // Stripe connect - if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); + } + + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $permissiontowrite = $user->rights->societe->creer; @@ -1082 +923 @@ - print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', 0, 2, 'socid'); + print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); @@ -1084,3 +925,4 @@ - print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontoaddupdatepaymentinformation, 'string', '', null, null, '', 2, '', 'socid'); - if (isModEnabled('stripe') && $stripesupplieracc && $action != 'editkey_account_supplier') { - $connect = ''; + print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); + if (!empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') + { + $connect = ''; @@ -1089 +931,2 @@ - if ($servicestatus) { + if ($servicestatus) + { @@ -1095 +938,2 @@ - if (empty($stripesupplieracc)) { + if (empty($stripesupplieracc)) + { @@ -1101 +945 @@ - //print ''; + //print ''; @@ -1110 +954 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -1114,21 +958,20 @@ - $showcardpaymentmode = 0; - if (isModEnabled('stripe')) { - $showcardpaymentmode++; - } - - // Get list of remote payment modes - $listofsources = array(); - - if (isset($stripe) && is_object($stripe)) { - try { - $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); - if (!empty($customerstripe->id)) { - // When using the Charge API architecture - if (!getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) { - $listofsources = $customerstripe->sources->data; - } else { - $service = 'StripeTest'; - $servicestatus = 0; - if (getDolGlobalString('STRIPE_LIVE') && !GETPOST('forcesandbox', 'alpha')) { - $service = 'StripeLive'; - $servicestatus = 1; + // List of Stripe payment modes + if (!(empty($conf->stripe->enabled)) && $object->client) + { + $morehtmlright = ''; + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + { + $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); + } + print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); + + $listofsources = array(); + if (is_object($stripe)) + { + try { + $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); + if ($customerstripe->id) { + // When using the Charge API architecture + if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + $listofsources = $customerstripe->sources->data; @@ -1136,12 +979,8 @@ - - // Force to use the correct API key - global $stripearrayofkeysbyenv; - \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); - - try { - if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage - $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card")); - $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit")); - } else { - $paymentmethodobjsA = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"), array("stripe_account" => $stripeacc)); - $paymentmethodobjsB = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "sepa_debit"), array("stripe_account" => $stripeacc)); + else + { + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) + { + $service = 'StripeLive'; + $servicestatus = 1; @@ -1150,6 +989,12 @@ - if ($paymentmethodobjsA->data != null && $paymentmethodobjsB->data != null) { - $listofsources = array_merge((array) $paymentmethodobjsA->data, (array) $paymentmethodobjsB->data); - } elseif ($paymentmethodobjsB->data != null) { - $listofsources = $paymentmethodobjsB->data; - } else { - $listofsources = $paymentmethodobjsA->data; + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); + + try { + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $paymentmethodobjs = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card")); + } else { + $paymentmethodobjs = \Stripe\PaymentMethod::all(array("customer" => $customerstripe->id, "type" => "card"), array("stripe_account" => $stripeacc)); + } + + $listofsources = $paymentmethodobjs->data; @@ -1157,3 +1002,5 @@ - } catch (Exception $e) { - $error++; - setEventMessages($e->getMessage(), null, 'errors'); + catch (Exception $e) + { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } @@ -1163,16 +1010,7 @@ - } catch (Exception $e) { - dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); - } - } - - - // List of Card payment modes - if ($showcardpaymentmode && $object->client) { - $morehtmlright = ''; - if (getDolGlobalString('STRIPE_ALLOW_LOCAL_CARD')) { - $morehtmlright .= dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard'); - } - print load_fiche_titre($langs->trans('CreditCard'), $morehtmlright, 'fa-credit-card'); - //($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)') - - print ''."\n"; + catch (Exception $e) + { + dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); + } + } + + print ''."\n"; @@ -1181,0 +1020,4 @@ + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + { + print ''.$langs->trans('LocalID').''; + } @@ -1183 +1025 @@ - print ''.$form->textwithpicto($langs->trans('ExternalSystemID'), $langs->trans("IDOfPaymentInAnExternalSystem")).''; // external system ID + print ''.$langs->trans('StripeID').''; @@ -1200 +1042 @@ - $arrayofremotecard = array(); + $arrayofstripecard = array(); @@ -1203 +1045,2 @@ - if (getDolGlobalString('STRIPE_ALLOW_LOCAL_CARD')) { + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + { @@ -1209,2 +1052,2 @@ - $sql .= " AND fk_soc = ".((int) $object->id); - $sql .= " AND status = ".((int) $servicestatus); + $sql .= " AND fk_soc = ".$object->id; + $sql .= " AND status = ".$servicestatus; @@ -1213 +1056,2 @@ - if ($resql) { + if ($resql) + { @@ -1215 +1059,2 @@ - if ($num_rows) { + if ($num_rows) + { @@ -1217 +1062,2 @@ - while ($i < $num_rows) { + while ($i < $num_rows) + { @@ -1221 +1067,2 @@ - if ($obj) { + if ($obj) + { @@ -1224,6 +1071,5 @@ - $arrayofremotecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; - - print ''; - // Label - print ''; - print dol_escape_htmltag($companypaymentmodetemp->label); + $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; + + print ''; + print ''; + print $companypaymentmodetemp->id; @@ -1231,14 +1077,13 @@ - // External system card ID - print ''; - if (!empty($companypaymentmodetemp->stripe_card_ref) && !empty($companypaymentmodetemp->ext_payment_site)) { - if (isModEnabled('stripe') && in_array($companypaymentmodetemp->ext_payment_site, array('StripeTest', 'StripeLive'))) { - $connect = ''; - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } - if ($companypaymentmodetemp->ext_payment_site == 'StripeLive') { - $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; - } else { - $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; - } - print "".img_picto($langs->trans('ShowInStripe').' - '.$companypaymentmodetemp->stripe_account, 'globe')." "; + print ''; + print $companypaymentmodetemp->label; + print ''; + print ''; + print $companypaymentmodetemp->stripe_card_ref; + if ($companypaymentmodetemp->stripe_card_ref) + { + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$companypaymentmodetemp->stripe_card_ref; + if ($servicestatus) + { + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$companypaymentmodetemp->stripe_card_ref; @@ -1246 +1091 @@ - // TODO Add hook here for other payment services + print ' '.img_picto($langs->trans('ShowInStripe').' - Customer and Publishable key = '.$companypaymentmodetemp->stripe_account, 'globe').''; @@ -1248 +1092,0 @@ - print dol_escape_htmltag($companypaymentmodetemp->stripe_card_ref); @@ -1250 +1093,0 @@ - // Type @@ -1254,15 +1097,7 @@ - // Information (Owner, ...) - print ''; - if ($companypaymentmodetemp->proprio) { - print ''.$companypaymentmodetemp->proprio.'
'; - } - if ($companypaymentmodetemp->last_four) { - print '....'.$companypaymentmodetemp->last_four; - } - if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) { - print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year; - } - print ''; - // Country - print ''; - if ($companypaymentmodetemp->country_code) { + print ''; + if ($companypaymentmodetemp->proprio) print ''.$companypaymentmodetemp->proprio.'
'; + if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four; + if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; + print ''; + if ($companypaymentmodetemp->country_code) + { @@ -1272,2 +1106,0 @@ - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1274,0 +1108 @@ + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1278,2 +1112,3 @@ - if (empty($companypaymentmodetemp->default_rib)) { - print ''; + if (empty($companypaymentmodetemp->default_rib)) + { + print ''; @@ -1286,7 +1121,3 @@ - if (empty($companypaymentmodetemp->stripe_card_ref)) { - $s = $langs->trans("Local"); - } else { - $s = $langs->trans("LocalAndRemote"); - } - print ''; - print $s; + print ''; + if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local"); + else print $langs->trans("LocalAndRemote"); @@ -1302,3 +1133,5 @@ - print ''; - if ($permissiontoaddupdatepaymentinformation) { - if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) { + print ''; + if ($user->rights->societe->creer) + { + if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) + { @@ -1308 +1141 @@ - print ''; + print ''; @@ -1311 +1144,2 @@ - print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& + print ' '; + print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& @@ -1321,3 +1155,2 @@ - } else { - dol_print_error($db); - } + } + else dol_print_error($db); @@ -1327,5 +1160,5 @@ - if (is_array($listofsources) && count($listofsources)) { - foreach ($listofsources as $src) { - if (!empty($arrayofremotecard[$src->id])) { - continue; // Already in previous list - } + if (is_array($listofsources) && count($listofsources)) + { + foreach ($listofsources as $src) + { + if (!empty($arrayofstripecard[$src->id])) continue; // Already in previous list @@ -1335,13 +1167,0 @@ - $imgline = ''; - if ($src->object == 'card') { - $imgline = img_credit_card($src->brand); - } elseif ($src->object == 'source' && $src->type == 'card') { - $imgline = img_credit_card($src->card->brand); - } elseif ($src->object == 'payment_method' && $src->type == 'card') { - $imgline = img_credit_card($src->card->brand); - } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { - continue; - } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { - continue; - } - @@ -1348,0 +1169,6 @@ + // Local ID + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) + { + print ''; + print ''; + } @@ -1352 +1178 @@ - print ''; + print ''; @@ -1354,3 +1180,2 @@ - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } + print $src->id; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; @@ -1359,6 +1184,6 @@ - if ($servicestatus) { - //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; - $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; - } - print "".img_picto($langs->trans('ShowInStripe'), 'globe')." "; - print $src->id; + if ($servicestatus) + { + //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; + $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; + } + print " ".img_picto($langs->trans('ShowInStripe'), 'globe').""; @@ -1366 +1191 @@ - // Img + // Img of credit card @@ -1368 +1193,20 @@ - print $imgline; + if ($src->object == 'card') + { + print img_credit_card($src->brand); + } + elseif ($src->object == 'source' && $src->type == 'card') + { + print img_credit_card($src->card->brand); + } + elseif ($src->object == 'source' && $src->type == 'sepa_debit') + { + print ''; + } + elseif ($src->object == 'payment_method' && $src->type == 'card') + { + print img_credit_card($src->card->brand); + } + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') + { + print ''; + } @@ -1372,2 +1216,3 @@ - if ($src->object == 'card') { - print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year; + if ($src->object == 'card') + { + print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; @@ -1375 +1220,2 @@ - if ($src->country) { + if ($src->country) + { @@ -1379,2 +1224,0 @@ - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1382,2 +1226,5 @@ - } elseif ($src->object == 'source' && $src->type == 'card') { - print ''.$src->owner->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year; + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + elseif ($src->object == 'source' && $src->type == 'card') + { + print ''.$src->owner->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; @@ -1386 +1233,2 @@ - if ($src->card->country) { + if ($src->card->country) + { @@ -1390,2 +1237,0 @@ - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1393,2 +1239,5 @@ - } elseif ($src->object == 'source' && $src->type == 'sepa_debit') { - print ''.$src->billing_details->name.'
....'.$src->sepa_debit->last4; + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + elseif ($src->object == 'source' && $src->type == 'sepa_debit') + { + print 'SEPA debit'; @@ -1396 +1245,27 @@ - if ($src->sepa_debit->country) { + if ($src->sepa_debit->country) + { + $img = picto_from_langcode($src->sepa_debit->country); + print $img ? $img.' ' : ''; + print getCountry($src->sepa_debit->country, 1); + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + elseif ($src->object == 'payment_method' && $src->type == 'card') + { + print ''.$src->billing_details->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; + print ''; + + if ($src->card->country) + { + $img = picto_from_langcode($src->card->country); + print $img ? $img.' ' : ''; + print getCountry($src->card->country, 1); + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') + { + print 'SEPA debit'; + print ''; + if ($src->sepa_debit->country) + { @@ -1400,2 +1274,0 @@ - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; @@ -1403,22 +1276,3 @@ - } elseif ($src->object == 'payment_method' && $src->type == 'card') { - print ''.$src->billing_details->name.'
....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year; - print ''; - - if ($src->card->country) { - $img = picto_from_langcode($src->card->country); - print $img ? $img.' ' : ''; - print getCountry($src->card->country, 1); - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; - } - } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { - print ''.$src->billing_details->name.'
....'.$src->sepa_debit->last4; - print ''; - if ($src->sepa_debit->country) { - $img = picto_from_langcode($src->sepa_debit->country); - print $img ? $img.' ' : ''; - print getCountry($src->sepa_debit->country, 1); - } else { - print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; - } - } else { + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + else { @@ -1431,2 +1285,3 @@ - (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) { - print ''; + (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) + { + print ''; @@ -1443 +1297,0 @@ - @@ -1445,0 +1300 @@ + print ''; @@ -1447 +1301,0 @@ - @@ -1452 +1305,0 @@ - @@ -1455,2 +1308,3 @@ - if ($permissiontoaddupdatepaymentinformation) { - print ''; + if ($user->rights->societe->creer) + { + print ''; @@ -1466,3 +1320,5 @@ - if ($nbremote == 0 && $nblocal == 0) { - $colspan = (getDolGlobalString('STRIPE_ALLOW_LOCAL_CARD') ? 10 : 9); - print ''.$langs->trans("None").''; + if ($nbremote == 0 && $nblocal == 0) + { + $colspan = 8; + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) $colspan++; + print ''.$langs->trans("None").''; @@ -1472,7 +1328,8 @@ - print '
'; - } - - // List of Stripe connect accounts - if (isModEnabled('stripe') && !empty($conf->stripeconnect->enabled) && !empty($stripesupplieracc)) { - print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, 'stripe-s'); - $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); + print '
'; + } + + // List of Stripe payment modes + if (!empty($conf->stripe->enabled) && !empty($conf->stripeconnect->enabled) && $object->fournisseur && !empty($stripesupplieracc)) + { + print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc ? ' (Stripe connection with StripeConnect account '.$stripesupplieracc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); + $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); @@ -1484,9 +1341,11 @@ - print ''.$langs->trans('Total').''; - print ''; - - $currencybalance = array(); - if (is_array($balance->available) && count($balance->available)) { - foreach ($balance->available as $cpt) { - $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); - if (!in_array($cpt->currency, $arrayzerounitcurrency)) { - $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; + print ''.$langs->trans('Total').''; + print ''; + + $currencybalance = array(); + if (is_array($balance->available) && count($balance->available)) + { + foreach ($balance->available as $cpt) + { + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (!in_array($cpt->currency, $arrayzerounitcurrency)) { + $currencybalance[$cpt->currency]['available'] = $cpt->amount / 100; @@ -1500,2 +1359,4 @@ - if (is_array($balance->pending) && count($balance->pending)) { - foreach ($balance->pending as $cpt) { + if (is_array($balance->pending) && count($balance->pending)) + { + foreach ($balance->pending as $cpt) + { @@ -1509,10 +1370,12 @@ - } - - if (is_array($currencybalance)) { - foreach ($currencybalance as $cpt) { - print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price(isset($cpt->pending) ? $cpt->pending : 0, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + (isset($cpt->pending) ? $cpt->pending : 0), 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; - } - } - - print ''; - print '
'; + } + + if (is_array($currencybalance)) + { + foreach ($currencybalance as $cpt) + { + print ''.$langs->trans("Currency".strtoupper($cpt['currency'])).''.price($cpt['available'], 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''.price($cpt['available'] + $cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt['currency'])).''; + } + } + + print ''; + print '
'; @@ -1522,3 +1385,2 @@ - if ($permissiontoaddupdatepaymentinformation) { - $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&action=create'); - } + + $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create'); @@ -1528,4 +1389,0 @@ - $nblocal = 0; - $nbremote = 0; - $arrayofremoteban = array(); - @@ -1533,3 +1391,3 @@ - - if (is_array($rib_list)) { - print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table + if (is_array($rib_list)) + { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -1539,2 +1397 @@ - print_liste_field_titre("Label"); - print_liste_field_titre($form->textwithpicto($langs->trans('ExternalSystemID'), $langs->trans("IDOfPaymentInAnExternalSystem"))); // external system ID + print_liste_field_titre("LabelRIB"); @@ -1545 +1402,2 @@ - if (isModEnabled('prelevement')) { + if (!empty($conf->prelevement->enabled)) + { @@ -1550,4 +1408 @@ - print_liste_field_titre("Default", '', '', '', '', '', '', '', 'center '); - if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT') && getDolGlobalInt("SOCIETE_RIB_ALLOW_ONLINESIGN")) { - print_liste_field_titre('', '', '', '', '', '', '', '', 'center '); - } + print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center '); @@ -1555,5 +1410 @@ - // Fields from hook - $parameters = array('arrayfields'=>array(), 'linetype'=>'stripebantitle'); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); @@ -1562,6 +1413,2 @@ - // List of local BAN - foreach ($rib_list as $rib) { - $arrayofremoteban[$rib->stripe_card_ref] = $rib->stripe_card_ref; - - $nblocal++; - + foreach ($rib_list as $rib) + { @@ -1570,20 +1417 @@ - print ''.dol_escape_htmltag($rib->label).''; - // External system ID - print ''; - if (!empty($rib->stripe_card_ref) && !empty($rib->ext_payment_site)) { - if (isModEnabled('stripe') && in_array($rib->ext_payment_site, array('StripeTest', 'StripeLive'))) { - $connect = ''; - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } - if ($rib->ext_payment_site == 'StripeLive') { - $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$rib->stripe_card_ref; - } else { - $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$rib->stripe_card_ref; - } - print "".img_picto($langs->trans('ShowInStripe'), 'globe')." "; - } - // TODO Add hook here for other payment services - } - print dol_escape_htmltag($rib->stripe_card_ref); - print ''; + print ''.$rib->label.''; @@ -1591 +1419 @@ - print ''.dol_escape_htmltag($rib->bank).''; + print ''.$rib->bank.''; @@ -1592,0 +1421 @@ + print ''; @@ -1604,5 +1433,5 @@ - // Already output after - // } elseif ($val == 'BIC') { - // $string .= $rib->bic.' '; - // } elseif ($val == 'IBAN') { - // $string .= $rib->iban.' ';*/ + // Already output after + // } elseif ($val == 'BIC') { + // $string .= $rib->bic.' '; + // } elseif ($val == 'IBAN') { + // $string .= $rib->iban.' ';*/ @@ -1618 +1447 @@ - print ''; + @@ -1622,2 +1451,2 @@ - print ''; - if (!empty($rib->iban)) { + print ''.$rib->iban; + if (!empty($rib->iban)) { @@ -1625,4 +1454,3 @@ - print img_picto($langs->trans("IbanNotValid"), 'warning').' '; - } - } - print dol_escape_htmltag($rib->iban); + print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); + } + } @@ -1631 +1459 @@ - print ''; + print ''.$rib->bic; @@ -1634,4 +1462,3 @@ - print img_picto($langs->trans("SwiftNotValid"), 'warning').' '; - } - } - print dol_escape_htmltag($rib->bic); + print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); + } + } @@ -1640 +1467,2 @@ - if (isModEnabled('prelevement')) { + if (!empty($conf->prelevement->enabled)) + { @@ -1643 +1471 @@ - print ''.dol_escape_htmltag($rib->rum).''; + print ''.$rib->rum.''; @@ -1647,2 +1475,2 @@ - // FRST or RCUR - print ''.dol_escape_htmltag($rib->frstrecur).''; + // FRSTRECUR + print ''.$rib->frstrecur.''; @@ -1654 +1482 @@ - print ''; + print ''; @@ -1672,2 +1500,3 @@ - if (is_array($modellist) && count($modellist)) { - $out .= '
'; + if (is_array($modellist) && count($modellist)) + { + $out .= ''; @@ -1679 +1508,2 @@ - if (is_array($modellist) && count($modellist) == 1) { // If there is only one element + if (is_array($modellist) && count($modellist) == 1) // If there is only one element + { @@ -1683,5 +1513,3 @@ - if (getDolGlobalString('BANKADDON_PDF')) { - $modelselected = $conf->global->BANKADDON_PDF; - } - - $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100 maxwidth125'); + if (!empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; + + $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); @@ -1690,2 +1517,0 @@ - $allowgenifempty = 0; - @@ -1693 +1519,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if ($conf->global->MAIN_MULTILANGS) + { @@ -1696 +1523 @@ - $defaultlang = $langs->getDefaultLang(); + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); @@ -1698,3 +1525 @@ - if ($conf->browser->layout == 'phone') { - $morecss = 'maxwidth100'; - } + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; @@ -1704 +1529 @@ - $genbutton = 'dol_no_mouse_hover) && $modulepart != 'unpaid') { + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') + { @@ -1714,6 +1538,2 @@ - if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { - $genbutton = ''; - } - if (empty($modellist) && !$showempty && $modulepart != 'unpaid') { - $genbutton = ''; - } + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; @@ -1726,16 +1545,0 @@ - // Fields from hook - $parameters = array('arrayfields'=>array(), 'stripe_card_ref'=>$rib->stripe_card_ref, 'stripe_account'=>$rib->stripe_account, 'linetype'=>'stripeban'); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - if (!getDolGlobalInt('SOCIETE_DISABLE_BANKACCOUNT') && getDolGlobalInt("SOCIETE_RIB_ALLOW_ONLINESIGN")) { - // Show online signature link - print ''; - $useonlinesignature = 1; - if ($useonlinesignature) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/signature.lib.php'; - print showOnlineSignatureUrl($companybankaccount->element, $rib->id); - } - print ''; - } - @@ -1744,17 +1548,3 @@ - if ($permissiontoaddupdatepaymentinformation) { - if (isModEnabled('stripe')) { - if (empty($rib->stripe_card_ref)) { - if ($object->client) { - // Add link to create BAN on Stripe - print ''; - print img_picto($langs->trans("CreateBANOnStripe"), 'stripe'); - print ''; - } else { - print ''; - print img_picto($langs->trans("ThirdPartyMustBeACustomerToCreateBANOnStripe"), 'stripe'); - print ''; - } - } - } - - print ''; + if ($user->rights->societe->creer) + { + print ''; @@ -1764,3 +1554,3 @@ - print ''; - print img_picto($langs->trans("Delete"), 'delete'); - print ''; + print ''; + print img_picto($langs->trans("Delete"), 'delete'); + print ''; @@ -1773,110 +1563,5 @@ - - // List of remote BAN (if not already added as local) - foreach ($listofsources as $src) { - if (!empty($arrayofremoteban[$src->id])) { - continue; // Already in previous list - } - - $imgline = ''; - if ($src->object == 'source' && $src->type == 'sepa_debit') { - $imgline = ''; - } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { - $imgline = ''; - } else { - continue; - } - - $nbremote++; - - print ''; - print ''; - print ''; - // Src ID - print ''; - $connect = ''; - if (!empty($stripeacc)) { - $connect = $stripeacc.'/'; - } - //$url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; - $url = 'https://dashboard.stripe.com/'.$connect.'test/search?query='.$src->id; - if ($servicestatus) { - //$url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; - $url = 'https://dashboard.stripe.com/'.$connect.'search?query='.$src->id; - } - print "".img_picto($langs->trans('ShowInStripe'), 'globe')." "; - print $src->id; - print ''; - // Bank - print ''; - print''; - // Account number - print ''; - print ''; - // IBAN - print ''; - //var_dump($src); - print ''; - // BIC - print ''; - //var_dump($src); - print ''; - - if (isModEnabled('prelevement')) { - // RUM - print ''; - //var_dump($src); - print ''; - // Date - print ''; - //var_dump($src); - print ''; - // Mode mandate - print ''; - //var_dump($src); - print ''; - } - - // Default - print ''; - if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) || - (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) { - print ''; - print img_picto($langs->trans("Default"), 'off'); - print ''; - } else { - print img_picto($langs->trans("Default"), 'on'); - } - print ''; - /* - print ''; - print $langs->trans("Remote"); - //if ($src->cvc_check == 'fail') print ' - CVC check fail'; - print ''; - */ - - print ''; - print ''; - - // Fields from hook - $parameters = array('arrayfields'=>array(), 'stripe_card_ref'=>$rib->stripe_card_ref, 'stripe_account'=>$rib->stripe_account, 'linetype'=>'stripebanremoteonly'); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action column - print ''; - if ($permissiontoaddupdatepaymentinformation) { - print ''; - print img_picto($langs->trans("Delete"), 'delete'); - print ''; - } - print ''; - - print ''; - } - - if ($nbremote == 0 && $nblocal == 0) { - $colspan = 10; - if (isModEnabled('prelevement')) { - $colspan += 3; - } - print ''.$langs->trans("NoBANRecord").''; + if (count($rib_list) == 0) + { + $colspan = 9; + if (!empty($conf->prelevement->enabled)) $colspan += 2; + print ''.$langs->trans("NoBANRecord").''; @@ -1891,6 +1576,3 @@ - //Hook to display your print listing (list of CB card from Stancer Plugin for example) - $parameters = array('arrayfields'=>array(), 'param'=>'', 'sortfield'=>'', 'sortorder'=>'', 'linetype'=>''); - $reshook = $hookmanager->executeHooks('printNewTable', $parameters, $object); - print $hookmanager->resPrint; - - if (!getDolGlobalString('SOCIETE_DISABLE_BUILDDOC')) { + + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) + { @@ -1903,2 +1585,2 @@ - * Generated documents - */ + * Documents generes + */ @@ -1907,2 +1589,4 @@ - - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $permissiontoread, $permissiontoaddupdatepaymentinformation, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); + $genallowed = $user->rights->societe->lire; + $delallowed = $user->rights->societe->creer; + + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); @@ -1911 +1595,2 @@ - if (getDolGlobalString('BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD')) { + if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) + { @@ -1919 +1604,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -1926,4 +1612,4 @@ - print '
'; - - - print '
'; + print '
'; + + + print '
'; @@ -1934,18 +1620,18 @@ - include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; - $modellist=ModeleBankAccountDoc::liste_modeles($db); - //print ''; - if (is_array($modellist) && count($modellist) == 1) // If there is only one element - { - $arraykeys=array_keys($modellist); - $modelselected=$arraykeys[0]; - } - $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); - $out.= ajax_combobox('model'); - //print $out; - $buttonlabel=$langs->trans("Generate"); - $genbutton = ''; // TODO Add link to generate doc - */ + include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; + $modellist=ModeleBankAccountDoc::liste_modeles($db); + //print ''; + if (is_array($modellist) && count($modellist) == 1) // If there is only one element + { + $arraykeys=array_keys($modellist); + $modelselected=$arraykeys[0]; + } + $out.= $form->selectarray('model', $modellist, $modelselected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out.= ajax_combobox('model'); + //print $out; + $buttonlabel=$langs->trans("Generate"); + $genbutton = ''; // TODO Add link to generate doc + */ @@ -1955,2 +1641,3 @@ -if ($socid && $action == 'edit' && $permissiontoaddupdatepaymentinformation) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); +if ($socid && $action == 'edit' && $user->rights->societe->creer) +{ + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); @@ -1963,2 +1649,0 @@ - - print '
'; @@ -1969 +1654 @@ - print ''.$langs->trans("Label").''; + print ''.$langs->trans("LabelRIB").''; @@ -1974,174 +1658,0 @@ - - // Show fields of bank account - $bankaccount = $companybankaccount; - // Code here is similare than into bank.php for users - foreach ($bankaccount->getFieldsToShow(1) as $val) { - $require = false; - $tooltip = ''; - if ($val == 'BankCode') { - $name = 'code_banque'; - $size = 8; - $content = $bankaccount->code_banque; - } elseif ($val == 'DeskCode') { - $name = 'code_guichet'; - $size = 8; - $content = $bankaccount->code_guichet; - } elseif ($val == 'BankAccountNumber') { - $name = 'number'; - $size = 18; - $content = $bankaccount->number; - } elseif ($val == 'BankAccountNumberKey') { - $name = 'cle_rib'; - $size = 3; - $content = $bankaccount->cle_rib; - } elseif ($val == 'IBAN') { - $name = 'iban'; - $size = 30; - $content = $bankaccount->iban; - if ($bankaccount->needIBAN()) { - $require = true; - } - $tooltip = $langs->trans("Example").':
CH93 0076 2011 6238 5295 7
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; - } elseif ($val == 'BIC') { - $name = 'bic'; - $size = 12; - $content = $bankaccount->bic; - if ($bankaccount->needIBAN()) { - $require = true; - } - $tooltip = $langs->trans("Example").': LIABLT2XXXX'; - } - - print ''; - print ''; - if ($tooltip) { - print $form->textwithpicto($langs->trans($val), $tooltip, 4, 'help', '', 0, 3, $name); - } else { - print $langs->trans($val); - } - print ''; - print ''; - print ''; - } - - print ''.$langs->trans("BankAccountDomiciliation").''; - print '"; - - print ''.$langs->trans("BankAccountOwner").''; - print ''; - print "\n"; - - print ''.$langs->trans("BankAccountOwnerAddress").''; - print '"; - - print ''; - print ''; - - if (isModEnabled('prelevement')) { - print '
'; - - print '
'; - print ''; - - if (empty($companybankaccount->rum)) { - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); - } - - // RUM - print ''; - print ''; - - $date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); - - print ''; - print ''; - - print ''; - - print '"; - print ''; - - print '
'.$langs->trans("RUM").'
'.$langs->trans("DateRUM").''.$form->selectDate($date_rum ? $date_rum : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum', 1, 1).'
'.$langs->trans("WithdrawMode").''; - $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RCUR" => $langs->trans("RECUR")); - print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ? GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0); - print '
'.$langs->trans("ExternalSystemID")." ('pm_...' or 'src_...')
'; - print '
'; - } - - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Modify"); -} - -// Edit Card -if ($socid && $action == 'editcard' && $permissiontoaddupdatepaymentinformation) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print '
'; - - print '
'; - - print '
'; - - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print '"; - print ''; - - print '
'.$langs->trans("Label").'
'.$langs->trans("NameOnCard").'
'.$langs->trans("CardNumber").'
'.$langs->trans("ExpiryDate").''; - print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1); - print $formother->selectyear($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); - print '
'.$langs->trans("CVN").'
'.$langs->trans("ExternalSystemID")." ('pm_... ".$langs->trans("or")." card_....')
'; - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Modify"); -} - - -// Create BAN -if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print '
'; - - print '
'; - - print '
'; - - print ''; - - print ''; - print ''; - - print ''; - print ''; @@ -2173,4 +1684,2 @@ - if ($companybankaccount->needIBAN()) { - $require = true; - } - $tooltip = $langs->trans("Example").':
CH93 0076 2011 6238 5295 7
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; + if ($companybankaccount->needIBAN()) $require = true; + $tooltip = $langs->trans("Example").':
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; @@ -2181,3 +1690 @@ - if ($companybankaccount->needIBAN()) { - $require = true; - } + if ($companybankaccount->needIBAN()) $require = true; @@ -2193,0 +1701,165 @@ + print ''; + print ''; + } + + print '"; + + print ''; + print ''; + print "\n"; + + print '"; + + print '
'.$langs->trans("Label").'
'.$langs->trans("Bank").'
'.$langs->trans("BankAccountDomiciliation").''; + print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwnerAddress").''; + print '
'; + print '
'; + + if ($conf->prelevement->enabled) + { + print '
'; + + print '
'; + print ''; + + if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); + + // RUM + print ''; + print ''; + + print ''; + print ''; + + print ''; + + print '
'.$langs->trans("RUM").'
'.$langs->trans("DateRUM").''.$form->selectDate(GETPOST('date_rum') ?GETPOST('date_rum') : $companybankaccount->date_rum, 'date_rum', 0, 0, 1, 'date_rum').'
'.$langs->trans("WithdrawMode").''; + $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); + print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0); + print '
'; + print '
'; + } + + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; +} + +// Edit Card +if ($socid && $action == 'editcard' && $user->rights->societe->creer) +{ + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print '"; + print ''; + + print '
'.$langs->trans("Label").'
'.$langs->trans("NameOnCard").'
'.$langs->trans("CardNumber").'
'.$langs->trans("ExpiryDate").''; + print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1); + print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); + print '
'.$langs->trans("CVN").'
'.$langs->trans("StripeID")." ('card_....')
'; + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; +} + + +// Create BAN +if ($socid && $action == 'create' && $user->rights->societe->creer) +{ + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print ''; + + print ''; + print ''; + + print ''; + print ''; + + // Show fields of bank account + foreach ($companybankaccount->getFieldsToShow(1) as $val) { + $require = false; + $tooltip = ''; + if ($val == 'BankCode') { + $name = 'code_banque'; + $size = 8; + $content = $companybankaccount->code_banque; + } elseif ($val == 'DeskCode') { + $name = 'code_guichet'; + $size = 8; + $content = $companybankaccount->code_guichet; + } elseif ($val == 'BankAccountNumber') { + $name = 'number'; + $size = 18; + $content = $companybankaccount->number; + } elseif ($val == 'BankAccountNumberKey') { + $name = 'cle_rib'; + $size = 3; + $content = $companybankaccount->cle_rib; + } elseif ($val == 'IBAN') { + $name = 'iban'; + $size = 30; + $content = $companybankaccount->iban; + if ($companybankaccount->needIBAN()) $require = true; + $tooltip = $langs->trans("Example").':
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; + } elseif ($val == 'BIC') { + $name = 'bic'; + $size = 12; + $content = $companybankaccount->bic; + if ($companybankaccount->needIBAN()) $require = true; + $tooltip = $langs->trans("Example").': LIABLT2XXXX'; + } + + print ''; + if ($tooltip) { + print $form->textwithpicto($langs->trans($val), $tooltip, 4, 'help', '', 0, 3, $name); + } else { + print $langs->trans($val); + } + print ''; @@ -2198 +1870 @@ - print ''; - print ''; - - $date_rum = dol_mktime(0, 0, 0, GETPOST('date_rummonth'), GETPOST('date_rumday'), GETPOST('date_rumyear')); + print ''; + print ''; @@ -2226 +1897 @@ - print ''; + print ''; @@ -2229 +1900 @@ - $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RCUR" => $langs->trans("RECUR")); + $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); @@ -2233,3 +1903,0 @@ - print '"; - print ''; - @@ -2241,5 +1909,9 @@ - print dol_get_fiche_end(); - - dol_set_focus('#bank'); - - print $form->buttonsSaveCancel("Add"); + dol_fiche_end(); + + dol_set_focus('#label'); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -2249,2 +1921,3 @@ -if ($socid && $action == 'createcard' && $permissiontoaddupdatepaymentinformation) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); +if ($socid && $action == 'createcard' && $user->rights->societe->creer) +{ + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); @@ -2259,3 +1931,0 @@ - - print '
'; - @@ -2276 +1946 @@ - print $formother->selectyear(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); + print $formother->select_year(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); @@ -2282 +1952 @@ - print '"; + print '"; @@ -2289 +1959 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -2293 +1963,5 @@ - print $form->buttonsSaveCancel("Add"); + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -2296 +1970,2 @@ -if ($socid && ($action == 'edit' || $action == 'editcard') && $permissiontoaddupdatepaymentinformation) { +if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) +{ @@ -2299 +1974,2 @@ -if ($socid && ($action == 'create' || $action == 'createcard') && $permissiontoaddupdatepaymentinformation) { +if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) +{ --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_price.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_price.php @@ -8 +7,0 @@ - * Copyright (C) 2023 Alexandre Spangaro @@ -30,2 +28,0 @@ - -// Load Dolibarr environment @@ -38 +35 @@ -if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { @@ -41 +38 @@ - $prodcustprice = new ProductCustomerPrice($db); + $prodcustprice = new Productcustomerprice($db); @@ -44,2 +40,0 @@ - -// Load translation files required by the page @@ -48,8 +43,3 @@ - -// Get parameters -$action = GETPOST('action', 'aZ09'); -$search_prod = GETPOST('search_prod', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); -$search_label = GETPOST('search_label', 'alpha'); -$search_price = GETPOST('search_price'); -$search_price_ttc = GETPOST('search_price_ttc'); +$action = GETPOST('action', 'alpha'); +$search_prod = GETPOST('search_prod', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); @@ -58,2 +48,2 @@ -$socid = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); -if ($user->socid) { +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) @@ -61 +50,0 @@ -} @@ -64 +52,0 @@ -// Initialize objects @@ -79,114 +67,110 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers - $search_prod = $search_label = $search_price = $search_price_ttc = ''; - } - - if ($action == 'add_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { - if (!(GETPOST('prodid', 'int') > 0)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors'); - $action = 'add_customer_price'; - } - - if (!$error) { - $update_child_soc = GETPOST('updatechildprice'); - - // add price by customer - $prodcustprice->fk_soc = $socid; - $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); - $prodcustprice->fk_product = GETPOST('prodid', 'int'); - $prodcustprice->price = price2num(GETPOST("price"), 'MU'); - $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); - $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - - $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' - - // We must define tva_tx, npr and local taxes - $vatratecode = ''; - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot - $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; - $localtax1 = 0; - $localtax2 = 0; - $localtax1_type = '0'; - $localtax2_type = '0'; - // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) { - // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. - $vatratecode = $reg[1]; - // Get record from code - $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code)."'"; - $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; - $sql .= " AND t.code = '".$db->escape($vatratecode)."'"; - $sql .= " AND t.entity IN (".getEntity('c_tva').")"; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $npr = $obj->recuperableonly; - $localtax1 = $obj->localtax1; - $localtax2 = $obj->localtax2; - $localtax1_type = $obj->localtax1_type; - $localtax2_type = $obj->localtax2_type; - } - } - - $prodcustprice->default_vat_code = $vatratecode; - $prodcustprice->tva_tx = $tva_tx; - $prodcustprice->recuperableonly = $npr; - $prodcustprice->localtax1_tx = $localtax1; - $prodcustprice->localtax2_tx = $localtax2; - $prodcustprice->localtax1_type = $localtax1_type; - $prodcustprice->localtax2_type = $localtax2_type; - - $result = $prodcustprice->create($user, 0, $update_child_soc); - - if ($result < 0) { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } else { - setEventMessages($langs->trans("Save"), null, 'mesgs'); - } - - $action = ''; - } - } - - if ($action == 'delete_customer_price' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { - // Delete price by customer - $prodcustprice->id = GETPOST('lineid', 'int'); - $result = $prodcustprice->delete($user); - - if ($result < 0) { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); - } else { - setEventMessages($langs->trans('RecordDeleted'), null, 'errors'); - } - $action = ''; - } - - if ($action == 'update_customer_price_confirm' && !$cancel && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) { - $prodcustprice->fetch(GETPOST('lineid', 'int')); - - $update_child_soc = GETPOST('updatechildprice'); - - // update price by customer - $prodcustprice->ref_customer = GETPOST('ref_customer', 'alpha'); - $prodcustprice->price = price2num(GETPOST("price"), 'MU'); - $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); - $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - $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) { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } else { - setEventMessages($langs->trans("Save"), null, 'mesgs'); - } - - $action = ''; - } +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers + { + $search_prod = ''; + } + + if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { + if (! (GETPOST('prodid', 'int') > 0)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Product")), null, 'errors'); + $action = 'add_customer_price'; + } + + if (! $error) { + $update_child_soc = GETPOST('updatechildprice'); + + // add price by customer + $prodcustprice->fk_soc = $socid; + $prodcustprice->fk_product = GETPOST('prodid', 'int'); + $prodcustprice->price = price2num(GETPOST("price"), 'MU'); + $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); + $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); + + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' + + // We must define tva_tx, npr and local taxes + $vatratecode = ''; + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; + // If value contains the unique code of vat line (new recommended method), we use it to find npr and local taxes + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. + $vatratecode = $reg[1]; + // Get record from code + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; + $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql .= " AND t.code ='".$vatratecode."'"; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $npr = $obj->recuperableonly; + $localtax1 = $obj->localtax1; + $localtax2 = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; + } + } + + $prodcustprice->default_vat_code = $vatratecode; + $prodcustprice->tva_tx = $tva_tx; + $prodcustprice->recuperableonly = $npr; + $prodcustprice->localtax1_tx = $localtax1; + $prodcustprice->localtax2_tx = $localtax2; + $prodcustprice->localtax1_type = $localtax1_type; + $prodcustprice->localtax2_type = $localtax2_type; + + $result = $prodcustprice->create($user, 0, $update_child_soc); + + if ($result < 0) { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } else { + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } + + $action = ''; + } + } + + if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) { + // Delete price by customer + $prodcustprice->id = GETPOST('lineid'); + $result = $prodcustprice->delete($user); + + if ($result < 0) { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); + } else { + setEventMessages($langs->trans('Delete'), null, 'errors'); + } + $action = ''; + } + + if ($action == 'update_customer_price_confirm' && !$_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { + $prodcustprice->fetch(GETPOST('lineid', 'int')); + + $update_child_soc = GETPOST('updatechildprice'); + + // update price by customer + $prodcustprice->price = price2num(GETPOST("price"), 'MU'); + $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); + $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); + $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) { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } else { + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } + + $action = ''; + } @@ -207 +191 @@ -if (isModEnabled('notification')) { +if (!empty($conf->notification->enabled)) @@ -209 +192,0 @@ -} @@ -212 +195 @@ -print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); +dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); @@ -221,8 +204,4 @@ -print '
'.$langs->trans("LabelRIB").'
'.$langs->trans("Bank").'
'.$langs->trans("BankAccountDomiciliation").''; + print '
'.$langs->trans("BankAccountDomiciliation").''; @@ -2207 +1879 @@ - print '
'.$langs->trans("BankAccountOwnerAddress").''; + print '
'.$langs->trans("BankAccountOwnerAddress").''; @@ -2214 +1886,2 @@ - if (isModEnabled('prelevement')) { + if ($conf->prelevement->enabled) + { @@ -2220,4 +1893,2 @@ - print '
'.$form->textwithpicto($langs->trans("RUM"), $langs->trans("RUMLong").'
'.$langs->trans("RUMWillBeGenerated")).'
'.$langs->trans("RUM").'
'.$langs->trans("RUMWillBeGenerated").'
'.$form->selectDate($date_rum, 'date_rum', 0, 0, 1, 'date_rum', 1, 1).'
'.$form->selectDate(GETPOST('date_rum'), 'date_rum', 0, 0, 1, 'date_rum').'
'.$langs->trans("ExternalSystemID")." ('src_....')
'.$langs->trans("ExternalSystemID")." ('card_....')
'.$langs->trans("StripeID")." ('card_....')
'; - -// Type Prospect/Customer/Supplier -print ''; - -if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field +print '
'.$langs->trans('NatureOfThirdParty').''; -print $object->getTypeUrl(1); -print '
'; + +if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +{ @@ -236,4 +215,2 @@ - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() != 0) + print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -247,4 +224,2 @@ - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() != 0) + print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -258,10 +233,10 @@ -print dol_get_fiche_end(); - - - -if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES')) { - $prodcustprice = new ProductCustomerPrice($db); - - $sortfield = GETPOST('sortfield', 'aZ09comma'); - $sortorder = GETPOST('sortorder', 'aZ09comma'); - $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +dol_fiche_end(); + + + +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + $prodcustprice = new Productcustomerprice($db); + + $sortfield = GETPOST("sortfield", 'alpha'); + $sortorder = GETPOST("sortorder", 'alpha'); + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -269,3 +244 @@ - if (empty($page) || $page == -1) { - $page = 0; - } // If $page is not defined, or '' or -1 + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -275 +248 @@ - if (!$sortorder) { + if (!$sortorder) @@ -277,2 +250 @@ - } - if (!$sortfield) { + if (!$sortfield) @@ -280,3 +252,2 @@ - } - - // Build filter to display only concerned lines + + // Build filter to display only concerned lines @@ -291,12 +261,0 @@ - if (!empty($search_label)) { - $filter ['prod.label'] = $search_label; - } - - if (!empty($search_price)) { - $filter ['t.price'] = $search_price; - } - - if (!empty($search_price_ttc)) { - $filter ['t.price_ttc'] = $search_price_ttc; - } - @@ -314,2 +272,0 @@ - print ''; - print ''; @@ -325,4 +281,0 @@ - // Ref. Customer - print ''; - print ''; - @@ -331 +284 @@ - print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, '', $object->id, 0, '', false, 1); + print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1); @@ -339 +292 @@ - print $form->selectPriceBaseType(GETPOST("price_base_type", "aZ09"), "price_base_type"); + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); @@ -348 +301,5 @@ - print ''; + if ($object->price_base_type == 'TTC') { + print ''; + } else { + print ''; + } @@ -355 +312,5 @@ - print ''; @@ -493 +457 @@ - print ''; + print ''; @@ -496,0 +461 @@ + print ''; @@ -500,5 +464,0 @@ - $userstatic = new User($db); - $userstatic->fetch($line->fk_user); - - print ''; - @@ -506 +465,0 @@ - print ''; @@ -516,0 +476,2 @@ + $userstatic = new User($db); + $userstatic->fetch($line->fk_user); @@ -518 +479 @@ - print $userstatic->getNomUrl(-1); + print $userstatic->getLoginUrl(1); @@ -520 +480,0 @@ - print ''; @@ -523 +483,3 @@ - } else { + } + else + { @@ -530,6 +492,11 @@ - } else { - // View mode - - /* - * Action bar - */ + } + else + { + // View mode + + /* ************************************************************************** */ + /* */ + /* Barre d'action */ + /* */ + /* ************************************************************************** */ + @@ -538,2 +505,2 @@ - if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { - print ''; + if ($user->rights->produit->creer || $user->rights->service->creer) { + print ''; @@ -544,147 +511,108 @@ - $arrayfields = array(); - foreach ($prodcustprice->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } - } - $arrayfields = dol_sort_array($arrayfields, 'position'); - - // Count total nb of records - $nbtotalofrecords = ''; - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $nbtotalofrecords = $prodcustprice->fetchAll('', '', 0, 0, $filter); - } - - $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); - if ($result < 0) { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); - } - - $option = '&search_prod='.$search_prod.'&id='.$object->id.'&label='.$search_label.'&price='.$search_price.'&price_ttc='.$search_price_ttc; - - print ''."\n"; - - print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); - - print ''; - print ''; - print ''; - if (!empty($sortfield)) { - print ''; - } - if (!empty($sortorder)) { - print ''; - } - print '
'; - print '
'.$langs->trans('RefCustomer').'
'; + if ($object->price_base_type == 'TTC') { + print ''; + } else { + print ''; + } @@ -369,3 +330,7 @@ - print $form->buttonsSaveCancel(); - - print ''; + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; @@ -378,2 +343,2 @@ - - if ($result <= 0) { + if ($result < 0) + { @@ -380,0 +346,35 @@ + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $staticprod = new Product($db); + $staticprod->fetch($prodcustprice->fk_product); + print ""; + print ''; + + // VAT + print ''; + + // Price base + print ''; + print ''; + print ''; + + // Price + print ''; + + // Price minimum + print ''; + + // Update all child soc + print ''; + print ''; + print ''; + + print '
'.$langs->trans('Product').'".$staticprod->getNomUrl(1)."
'.$langs->trans("VATRate").''; + print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); + print '
'; + print $langs->trans('PriceBase'); + print ''; + print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type"); + print '
'; + $text = $langs->trans('SellingPrice'); + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print ''; + if ($prodcustprice->price_base_type == 'TTC') { + print ''; @@ -382,69 +382,34 @@ - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $staticprod = new Product($db); - $staticprod->fetch($prodcustprice->fk_product); - print ""; - print ''; - - // Ref. Customer - print ''; - print ''; - - // VAT - print ''; - - // Price base - print ''; - print ''; - print ''; - - // Price - print ''; - - // Price minimum - print ''; - - // Update all child soc - print ''; - print ''; - print ''; - - print '
'.$langs->trans('Product').'".$staticprod->getNomUrl(1)."
'.$langs->trans('RefCustomer').'
'.$langs->trans("VATRate").''; - print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); - print '
'; - print $langs->trans('PriceBase'); - print ''; - print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type"); - print '
'; - $text = $langs->trans('SellingPrice'); - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - print ''; - if ($prodcustprice->price_base_type == 'TTC') { - print ''; - } else { - print ''; - } - print '
'; - $text = $langs->trans('MinPrice'); - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - print ''; - if ($prodcustprice->price_base_type == 'TTC') { - print ''; - } else { - print ''; - } - print '
'; - print $langs->trans('ForceUpdateChildPriceSoc'); - print ''; - print ''; - print '
'; - - print $form->buttonsSaveCancel(); - - print ''; - } + print ''; + } + print '
'; + $text = $langs->trans('MinPrice'); + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print ''; + if ($prodcustprice->price_base_type == 'TTC') { + print ''; + } else { + print ''; + } + print '
'; + print $langs->trans('ForceUpdateChildPriceSoc'); + print ''; + print ''; + print '
'; + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; @@ -452 +417 @@ - print '
'; + print '
'; @@ -456,2 +421 @@ - 't.fk_product' => GETPOST('prodid', 'int'), - 't.fk_soc' => $socid + 't.fk_product' => GETPOST('prodid', 'int'), 't.fk_soc' => $socid @@ -462,2 +426,7 @@ - $result = $prodcustprice->fetchAllLog($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); - if ($result < 0) { + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); + } + + $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); + if ($result < 0) + { @@ -465,4 +433,0 @@ - } else { - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - $nbtotalofrecords = $result; - } @@ -484 +448,0 @@ - print '
'.$langs->trans('RefCustomer').' 
'.$line->ref_customer.'
'; - - $param = 'socid='.$object->id.'&'; - if ($search_prod) { - $param .= '&search_prod='.urlencode($search_prod); - } - if ($search_label) { - $param .= '&search_label='.urlencode($search_label); - } - if ($search_price) { - $param .= '&search_price='.urlencode($search_price); - } - if ($search_price) { - $param .= '&search_price='.urlencode($search_price); - } - if ($search_price_ttc) { - $param .= '&search_price_ttc='.urlencode($search_price_ttc); - } - - print ''; - foreach ($prodcustprice->fields as $key => $val) { - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], $key, '', $param, '', $sortfield, $sortorder)."\n"; - } - } - print ''; - print ''; - - if (count($prodcustprice->lines) > 0 || $search_prod) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - // Print the search button - print ''; - print ''; - } - - if (count($prodcustprice->lines) > 0) { - foreach ($prodcustprice->lines as $line) { - $staticprod = new Product($db); - $staticprod->fetch($line->fk_product); - - $userstatic = new User($db); - $userstatic->fetch($line->fk_user); - - print ''; - - print '"; - print '"; - print ''; - print '"; - print '"; - print '"; - print '"; - print '"; - print ''; - print ''; - // User - print ''; - // Action - if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) { - print ''; - } - - print "\n"; - } - } else { - $colspan = 10; - if ($user->hasRight('produit', 'supprimer') || $user->hasRight('service', 'supprimer')) { - $colspan += 1; - } - print ''; - } - - print "
'; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'.$staticprod->getNomUrl(1)."'.$staticprod->label."'.$line->ref_customer.''.dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."'.price($line->price)."'.price($line->price_ttc)."'.price($line->price_min).''.price($line->price_min_ttc).''; - print $userstatic->getNomUrl(-1); - print ''; - print 'id.'&prodid='.$line->fk_product.'">'; - print img_info(); - print ''; - print ' '; - print 'id.'&lineid='.$line->id.'">'; - print img_edit('default', 0, 'style="vertical-align: middle;"'); - print ''; - print ' '; - print 'id.'&lineid='.$line->id.'">'; - print img_delete('default', 'style="vertical-align: middle;"'); - print ''; - print '
'.$langs->trans('None').'
"; - print '
'; - - print ""; + // Count total nb of records + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); + } + + $result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); + if ($result < 0) + { + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); + } + + $option = '&search_prod='.$search_prod.'&id='.$object->id; + + print ''."\n"; + + print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVER['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); + + print '
'; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if (count($prodcustprice->lines) > 0 || $search_prod) + { + print ''; + print ''; + print ''; + // Print the search button + print ''; + print ''; + } + + if (count($prodcustprice->lines) > 0) + { + foreach ($prodcustprice->lines as $line) + { + print ''; + + $staticprod = new Product($db); + $staticprod->fetch($line->fk_product); + + print ""; + print ""; + + print '"; + print '"; + print '"; + print '"; + print ''; + print ''; + + // User + $userstatic = new User($db); + $userstatic->fetch($line->fk_user); + print ''; + + // Action + if ($user->rights->produit->creer || $user->rights->service->creer) + { + print ''; + } + + print "\n"; + } + } + else + { + $colspan = 9; + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1; + print ''; + } + + print "
'.$langs->trans("Product").''.$langs->trans("AppliedPricesFrom").''.$langs->trans("PriceBase").''.$langs->trans("VAT").''.$langs->trans("HT").''.$langs->trans("TTC").''.$langs->trans("MinPrice").' '.$langs->trans("HT").''.$langs->trans("MinPrice").' '.$langs->trans("TTC").''.$langs->trans("ChangedBy").' 
 '; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
".$staticprod->getNomUrl(1)."".dol_print_date($line->datec, "dayhour")."'.$langs->trans($line->price_base_type)."'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."'.price($line->price)."'.price($line->price_ttc)."'.price($line->price_min).''.price($line->price_min_ttc).''; + print $userstatic->getLoginUrl(1); + print ''; + print 'id.'&prodid='.$line->fk_product.'">'; + print img_info(); + print ''; + print ' '; + print 'id.'&lineid='.$line->id.'">'; + print img_edit('default', 0, 'style="vertical-align: middle;"'); + print ''; + print ' '; + print 'id.'&lineid='.$line->id.'">'; + print img_delete('default', 'style="vertical-align: middle;"'); + print ''; + print '
'.$langs->trans('None').'
"; + + print "
"; --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_project.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_project.php @@ -9 +8,0 @@ - * Copyright (C) 2021 Frédéric France @@ -31,2 +29,0 @@ - -// Load Dolibarr environment @@ -36,2 +32,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -39,11 +34 @@ -$form = new Form($db); - -// Load translation files required by the page -$langs->loadLangs(array('companies', 'projects')); - -$action = GETPOST('action', 'aZ09'); -$massaction = GETPOST('massaction', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); - -$toselect = GETPOST('toselect', 'array'); - +$langs->loadLangs(array("companies", "projects")); @@ -53,3 +38 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -60,4 +42,0 @@ - -$object = new Societe($db); -$permissiontodelete = $user->hasRight('societe', 'supprimer'); - @@ -69,0 +49,3 @@ +$parameters = array('id'=>$socid); +$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'); @@ -71,35 +52,0 @@ -if (GETPOST('cancel', 'alpha')) { - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; - $massactionbutton = ''; -} - - -$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'); -} - -$parameters = array('id'=>$socid); - -// List of mass actions available -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { - $arrayofmassactions = array(); -} - -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) { - $arrayofmassactions = array(); -} - -// Mass actions -$objectclass = 'Project'; -$objectlabel = 'Project'; -$uploaddir = $conf->societe->dir_output; -include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; - -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -112,2 +59,6 @@ -unset($_SESSION['pageforbacktolist']['project']); -if ($socid) { +$contactstatic = new Contact($db); + +$form = new Form($db); + +if ($socid) +{ @@ -118,0 +70,2 @@ + + $object = new Societe($db); @@ -122,3 +75 @@ - if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->name." - ".$title; - } + if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title; @@ -127,3 +78 @@ - if (isModEnabled('notification')) { - $langs->load("mails"); - } + if (!empty($conf->notification->enabled)) $langs->load("mails"); @@ -132 +81 @@ - print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company'); @@ -134 +83 @@ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; @@ -136 +85 @@ - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); @@ -138 +87 @@ - print '
'; + print '
'; @@ -140 +89 @@ - print '
'; + print '
'; @@ -142,0 +92,4 @@ + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; + } @@ -144,10 +97,2 @@ - // Type Prospect/Customer/Supplier - print ''.$langs->trans('NatureOfThirdParty').''; - print $object->getTypeUrl(1); - print ''; - - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; - } - - if ($object->client) { + if ($object->client) + { @@ -156,5 +101,2 @@ - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -164 +106,2 @@ - if ($object->fournisseur) { + if ($object->fournisseur) + { @@ -167,5 +110,2 @@ - print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -175,0 +116 @@ + @@ -178 +119 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -180 +120,0 @@ - print '
'; @@ -182,2 +121,0 @@ - $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id; - $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params); @@ -185,5 +123,3 @@ - if (empty($conf->dol_optimize_smallscreen)) { - print '
'; - print ''; - print '
'.$massactionbutton.'
'; - } + $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopage='.urlencode($backtopage), '', 1, $params); + + print '
'; @@ -193,7 +129 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - $arrayofselected = is_array($toselect) ? $toselect : array(); - $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); - - if (empty($conf->dol_optimize_smallscreen)) { - print '
'; - } + $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_societecontact.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_societecontact.php @@ -26 +26 @@ - * \brief Tab to manage differently contact. Used when unstable feature MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES is on. + * \brief Onglet de gestion des contacts additionnel d'une société @@ -29,2 +28,0 @@ - -// Load Dolibarr environment @@ -37,5 +35,3 @@ -// Load translation files required by the page -$langs->loadLangs(array('companies', 'orders')); - -// Get parameters -$id = GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('socid', 'int'); +$langs->loadLangs(array("orders", "companies")); + +$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); @@ -43 +39 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -46,3 +42,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -50,9 +46,3 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "s.nom"; -} -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { - $page = 0; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "s.nom"; +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } @@ -64,3 +54 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -69,2 +56,0 @@ - -// Initialize objects @@ -81 +67,2 @@ -if ($action == 'addcontact' && $user->hasRight('societe', 'creer')) { +if ($action == 'addcontact' && $user->rights->societe->creer) +{ @@ -84,7 +71,8 @@ - if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - } - - if ($result >= 0) { + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { @@ -93,2 +81,5 @@ - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { @@ -97 +88,3 @@ - } else { + } + else + { @@ -101,5 +94,11 @@ -} elseif ($action == 'swapstatut' && $user->hasRight('societe', 'creer')) { - // bascule du statut d'un contact - if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } else { +} + +// bascule du statut d'un contact +elseif ($action == 'swapstatut' && $user->rights->societe->creer) +{ + if ($object->fetch($id)) + { + $result = $object->swapContactStatus(GETPOST('ligne')); + } + else + { @@ -108,2 +107,5 @@ -} elseif ($action == 'deletecontact' && $user->hasRight('societe', 'creer')) { - // Efface un contact +} + +// Efface un contact +elseif ($action == 'deletecontact' && $user->rights->societe->creer) +{ @@ -111,3 +113,4 @@ - $result = $object->delete_contact(GETPOST("lineid", 'int')); - - if ($result >= 0) { + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { @@ -116 +119,2 @@ - } else { + } + else { @@ -119,0 +124,7 @@ +/* +elseif ($action == 'setaddress' && $user->rights->societe->creer) +{ + $object->fetch($id); + $result=$object->setDeliveryAddress($_POST['fk_address']); + if ($result < 0) dol_print_error($db,$object->error); +}*/ @@ -137,4 +148,13 @@ -// View and edit - -if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { +/* *************************************************************************** */ +/* */ +/* Mode vue et edition */ +/* */ +/* *************************************************************************** */ + +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref) > 0) + { + $soc = new Societe($db); + $soc->fetch($object->socid); + @@ -142 +162 @@ - print dol_get_fiche_head($head, 'contact', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), -1, 'company'); @@ -147,7 +167,7 @@ - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print '
'; - - print '
'; + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; @@ -156,34 +176,31 @@ - // Prospect/Customer - /*print ''.$langs->trans('ProspectCustomer').''; - print $object->getLibCustProspStatut(); - print ''; - - // Supplier - print ''.$langs->trans('Supplier').''; - print yn($object->fournisseur); - print '';*/ - - if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field - print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; - } - - if ($object->client) { - print ''; - print $langs->trans('CustomerCode').''; - print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } - print ''; - } - - if ($object->fournisseur) { - print ''; - print $langs->trans('SupplierCode').''; - print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } - print ''; + // Prospect/Customer + /*print ''.$langs->trans('ProspectCustomer').''; + print $object->getLibCustProspStatut(); + print ''; + + // Supplier + print ''.$langs->trans('Supplier').''; + print yn($object->fournisseur); + print '';*/ + + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; + } + + if ($object->client) + { + print ''; + print $langs->trans('CustomerCode').''; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print ''; + } + + if ($object->fournisseur) + { + print ''; + print $langs->trans('SupplierCode').''; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print ''; @@ -200 +217,2 @@ - foreach ($dirtpls as $reldir) { + foreach ($dirtpls as $reldir) + { @@ -202,3 +220 @@ - if ($res) { - break; - } + if ($res) break; @@ -208 +224,2 @@ - if (isModEnabled('adherent') && $user->hasRight('adherent', 'lire')) { + if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) + { @@ -219 +236 @@ - $sql .= " t.libelle as type_label, t.subscription"; + $sql .= " t.libelle as type, t.subscription"; @@ -222 +239 @@ - $sql .= " WHERE d.fk_soc = ".((int) $id); + $sql .= " WHERE d.fk_soc = ".$id; @@ -227 +244,2 @@ - if ($resql) { + if ($resql) + { @@ -230 +248,2 @@ - if ($num > 0) { + if ($num > 0) + { @@ -251 +270,2 @@ - while ($i < $num && $i < $conf->liste_limit) { + while ($i < $num && $i < $conf->liste_limit) + { @@ -273,3 +293,3 @@ - print((!empty($objp->lastname) || !empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); - print(((!empty($objp->lastname) || !empty($objp->firstname)) && !empty($companyname)) ? ' / ' : ''); - print(!empty($companyname) ? dol_trunc($companyname, 32) : ''); + print ((!empty($objp->lastname) || !empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : ''); + print (((!empty($objp->lastname) || !empty($objp->firstname)) && !empty($companyname)) ? ' / ' : ''); + print (!empty($companyname) ? dol_trunc($companyname, 32) : ''); @@ -283,2 +303,2 @@ - $membertypestatic->libelle = $objp->type_label; // deprecated - $membertypestatic->label = $objp->type_label; + $membertypestatic->libelle = $objp->type; + $membertypestatic->label = $objp->type; @@ -302 +322,2 @@ - if ($datefin) { + if ($datefin) + { @@ -309 +330,3 @@ - } else { + } + else + { @@ -311 +334,2 @@ - if (!empty($objp->subscription)) { + if ($objp->subscription == 'yes') + { @@ -313,4 +337,4 @@ - if ($objp->statut > 0) { - print " ".img_warning(); - } - } else { + if ($objp->statut > 0) print " ".img_warning(); + } + else + { @@ -329 +353,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/societe/github_19.0.3_website.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_website.php @@ -31,2 +30,0 @@ - -// Load Dolibarr environment @@ -40,2 +37,0 @@ - -// Load translation files required by the page @@ -44,10 +40,4 @@ - -// Get parameters -$id = GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('socid', 'int'); - -$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$show_files = GETPOST('show_files', 'int'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'websitelist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$show_files = GETPOST('show_files', 'int'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page @@ -55,5 +45,11 @@ -$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); + +$search_status = GETPOST('search_status'); + +// Security check +$id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'societe', $socid, '&societe'); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -61,3 +57 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -67,7 +61,2 @@ -if (!$sortfield) { - $sortfield = 't.login'; -} -if (!$sortorder) { - $sortorder = 'ASC'; -} - +if (!$sortfield) $sortfield = 't.login'; +if (!$sortorder) $sortorder = 'ASC'; @@ -90 +79 @@ -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); @@ -92,4 +81,3 @@ -foreach ($objectwebsiteaccount->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } +foreach ($objectwebsiteaccount->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -100,4 +88,3 @@ -foreach ($objectwebsiteaccount->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } +foreach ($objectwebsiteaccount->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; @@ -108 +95,2 @@ -foreach ($objectwebsiteaccount->fields as $key => $val) { +foreach ($objectwebsiteaccount->fields as $key => $val) +{ @@ -110,3 +98 @@ - if (!empty($val['visible'])) { - $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); - } + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled']); @@ -116,2 +102,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -121 +113,3 @@ -if ($id > 0) { + +if ($id > 0) +{ @@ -124,7 +117,0 @@ - -// Security check -$id = GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('socid', 'int'); -if ($user->socid) { - $id = $user->socid; -} -$result = restrictedArea($user, 'societe', $object->id, '&societe'); @@ -137 +124 @@ -$parameters = array('id'=>$id); +$parameters = array('id'=>$socid); @@ -139,34 +126,37 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($objectwebsiteaccount->fields as $key => $val) { - $search[$key] = ''; - } - $toselect = array(); - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } - - // Mass actions - $objectclass = 'WebsiteAccount'; - $objectlabel = 'WebsiteAccount'; - $permissiontoread = $user->hasRight('societe', 'lire'); - $permissiontodelete = $user->hasRight('societe', 'supprimer'); - $uploaddir = $conf->societe->multidir_output[$object->entity]; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + foreach ($objectwebsiteaccount->fields as $key => $val) + { + $search[$key] = ''; + } + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'WebsiteAccount'; + $objectlabel = 'WebsiteAccount'; + $permissiontoread = $user->rights->societe->lire; + $permissiontodelete = $user->rights->societe->supprimer; + $uploaddir = $conf->societe->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -191,10 +181,5 @@ -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($id > 0) { - $param .= '&id='.urlencode($id); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -foreach ($search as $key => $val) { +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($id > 0) $param .= '&id='.urlencode($id); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +foreach ($search as $key => $val) +{ @@ -203,3 +188 @@ -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -211 +194 @@ -print dol_get_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company'); +dol_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company'); @@ -224 +207,2 @@ -if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field +if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +{ @@ -232,4 +216,2 @@ - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() != 0) + print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -243,4 +225,2 @@ - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() != 0) + print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -254 +234 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -257,2 +237,2 @@ -if (isModEnabled('website') || isModEnabled('webportal')) { - if ($user->hasRight('societe', 'lire')) { +if (!empty($conf->website->enabled)) { + if (!empty($user->rights->societe->lire)) { @@ -260,2 +240,2 @@ - } else { - $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0); + } else { + $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', 0); @@ -271,7 +250,0 @@ -$site_filter_list = array(); -if (isModEnabled('website')) { - $site_filter_list[] = 'dolibarr_website'; -} -if (isModEnabled('webportal')) { - $site_filter_list[] = 'dolibarr_portal'; -} @@ -279,2 +252,3 @@ -foreach ($objectwebsiteaccount->fields as $key => $val) { - $sql .= "t.".$key.", "; +foreach ($objectwebsiteaccount->fields as $key => $val) +{ + $sql .= 't.'.$key.', '; @@ -283,5 +257,2 @@ -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key." as options_".$key.', ' : ''); - } -} +if (!empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); @@ -294,13 +265,6 @@ -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} -if ($objectwebsiteaccount->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity('thirdpartyaccount').")"; -} else { - $sql .= " WHERE 1 = 1"; -} -$sql .= " AND fk_soc = ".((int) $object->id); -if (!empty($site_filter_list)) { - $sql .= " AND t.site IN (".$db->sanitize("'".implode("','", $site_filter_list)."'", 1).")"; -} -foreach ($search as $key => $val) { +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('societeaccount').")"; +else $sql .= " WHERE 1 = 1"; +$sql .= " AND fk_soc = ".$object->id; +foreach ($search as $key => $val) +{ @@ -308,7 +272,3 @@ - if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); +} +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); @@ -326 +286 @@ - $sql .= "t.".$key.", "; + $sql.='t.'.$key.', '; @@ -329 +289 @@ -if (!empty($extrafields->attributes[$object->table_element]['label'])) { +if (! empty($extrafields->attributes[$object->table_element]['label'])) { @@ -341 +301,2 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ @@ -344 +305,2 @@ - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -353 +315,2 @@ -if (!$resql) { +if (!$resql) +{ @@ -367,6 +330,2 @@ -if ($user->hasRight('mymodule', 'delete')) { - $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -} -if (in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} +if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -376,3 +335 @@ -if ($optioncss != '') { - print ''; -} +if ($optioncss != '') print ''; @@ -409,7 +366,5 @@ -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (!empty($moreforfilter)) +{ @@ -422 +377 @@ -$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -426 +381 @@ -print ''."\n"; +print '
'."\n"; @@ -432,8 +387,2 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} -foreach ($objectwebsiteaccount->fields as $key => $val) { +foreach ($objectwebsiteaccount->fields as $key => $val) +{ @@ -441,12 +390,4 @@ - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $align = 'center'; - } - if (in_array($val['type'], array('timestamp'))) { - $align .= ' nowrap'; - } - if ($key == 'status') { - $align .= ($align ? ' ' : '').'center'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - } + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; + if (in_array($val['type'], array('timestamp'))) $align .= ' nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print ''; @@ -461,6 +402,4 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; -} +print ''; @@ -469,3 +407,0 @@ - -$totalarray = array(); -$totalarray['nbfield'] = 0; @@ -476,21 +412,7 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -foreach ($objectwebsiteaccount->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n"; - $totalarray['nbfield']++; - } +foreach ($objectwebsiteaccount->fields as $key => $val) +{ + $align = ''; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; + if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; @@ -505,5 +427 @@ -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n"; - $totalarray['nbfield']++; -} +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n"; @@ -515,5 +433,5 @@ -if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (!is_null($val) && preg_match('/\$object/', $val)) { - $needToFetchEachLine++; // There is at least one compute field that use $object - } +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object @@ -526,2 +444,3 @@ -$totalarray = array('nbfield' => 0); -while ($i < min($num, $limit)) { +$totalarray = array(); +while ($i < min($num, $limit)) +{ @@ -529,3 +448 @@ - if (empty($obj)) { - break; // Should not happen - } + if (empty($obj)) break; // Should not happen @@ -537,4 +454,3 @@ - foreach ($objectwebsiteaccount->fields as $key => $val) { - if (property_exists($objectwebsiteaccount, $key)) { - $objectwebsiteaccount->$key = $obj->$key; - } + foreach ($objectwebsiteaccount->fields as $key => $val) + { + if (property_exists($obj, $key)) $object->$key = $obj->$key; @@ -545,16 +461,2 @@ - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - foreach ($objectwebsiteaccount->fields as $key => $val) { + foreach ($objectwebsiteaccount->fields as $key => $val) + { @@ -562,10 +464,5 @@ - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $align = 'center'; - } - if (in_array($val['type'], array('timestamp'))) { - $align .= 'nowrap'; - } - if ($key == 'status') { - $align .= ($align ? ' ' : '').'center'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align = 'center'; + if (in_array($val['type'], array('timestamp'))) $align .= 'nowrap'; + if ($key == 'status') $align .= ($align ? ' ' : '').'center'; + if (!empty($arrayfields['t.'.$key]['checked'])) + { @@ -573,3 +470 @@ - if ($align) { - print ' class="'.$align.'"'; - } + if ($align) print ' class="'.$align.'"'; @@ -577,5 +472,2 @@ - if ($key == 'login') { - print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); - } else { - print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, ''); - } + if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); + else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, ''); @@ -583,14 +475,5 @@ - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $objectwebsiteaccount->$key; + if (!$i) $totalarray['nbfield']++; + if (!empty($val['isameasure'])) + { + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; @@ -607,14 +490,10 @@ - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + print ''; + if (!$i) $totalarray['nbfield']++; + @@ -631 +510,2 @@ -if ($num == 0) { +if ($num == 0) +{ @@ -633,6 +513,2 @@ - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''; @@ -653 +529,2 @@ -if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) +{ @@ -655,3 +532 @@ - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'