--- /tmp/dsg/dolibarr/htdocs/societe/github_agenda.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_agenda.php @@ -36,10 +36,12 @@ 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' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} +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)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -73,19 +75,19 @@ if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } - // 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 = ''; + } } @@ -111,66 +113,74 @@ if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); - print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, 'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; - $object->info($socid); + $object->info($socid); dol_print_object_info($object, 1); print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); // Actions buttons - $objthirdparty = $object; - $objcon = new stdClass(); + $objthirdparty = $object; + $objcon = new stdClass(); - $out = ''; - $permok = $user->rights->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 : '').'&percentage=-1'; - $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); + $out = ''; + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) + { + //$out.='trans("AddAnAction"),'filenew'); + //$out.=""; } + + //print '
'; + //print '
'; + + $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); - } - } + 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); + } + } - if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) - { - print '
'; + 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; + $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); + //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); - // List of all actions + // List of all actions $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; + $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); - } + // TODO Replace this with same code than into list.php + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + } } // End of page --- /tmp/dsg/dolibarr/htdocs/societe/github_ajaxcompanies.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_ajaxcompanies.php @@ -64,18 +64,20 @@ $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)."%'"; - } + $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 .= ")"; } @@ -88,19 +90,23 @@ { while ($row = $db->fetch_array($resql)) { - $label = $row['nom']; - if ($socid) $label = preg_replace('/('.preg_quote($socid, '/').')/i', '$1', $label, 1); + $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']; + $row_array['key'] = $row['rowid']; - array_push($return_arr, $row_array); - } + array_push($return_arr, $row_array); + } - echo json_encode($return_arr); - } else { - echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); + echo json_encode($return_arr); } -} else { - echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); + 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_card.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_card.php @@ -85,31 +85,22 @@ } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$object->getCanvas($socid); $canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); $objcanvas = null; if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('thirdparty', 'card', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('thirdparty', 'card', $canvas); } // Security check -$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); - -/* -if ($object->id > 0) { - if ($object->client == 0 && $object->fournisseur > 0) { - if (!empty($user->rights->fournisseur->lire)) { - accessforbidden(); - } - } -} -*/ +$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->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0); +$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]; @@ -125,15 +116,15 @@ if (empty($reshook)) { - if ($cancel) - { - $action = ''; - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - } + if ($cancel) + { + $action = ''; + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer) { @@ -145,7 +136,9 @@ { $langs->load('errors'); setEventMessages($langs->trans('ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv('MergeOriginThirdparty')), null, 'errors'); - } else { + } + else + { if (!$error && $soc_origin->fetch($soc_origin_id) < 1) { setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); @@ -154,7 +147,7 @@ if (!$error) { - // TODO Move the merge function into class of object. + // TODO Move the merge function into class of object. $db->begin(); @@ -176,11 +169,11 @@ // Concat some data $listofproperties = array( - 'note_public', 'note_private' + 'note_public', 'note_private' ); foreach ($listofproperties as $property) { - $object->$property = dol_concatdesc($object->$property, $soc_origin->$property); + $object->$property = dol_concatdesc($object->$property, $soc_origin->$property); } // Merge extrafields @@ -188,7 +181,7 @@ { foreach ($soc_origin->array_options as $key => $val) { - if (empty($object->array_options[$key])) $object->array_options[$key] = $val; + if (empty($object->array_options[$key])) $object->array_options[$key] = $val; } } @@ -228,11 +221,8 @@ // Move links if (!$error) { - // This list is also into the api_thirdparties.class.php - // TODO Mutualise the list into object societe.class.php $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', - 'Don' => '/don/class/don.class.php', 'Societe' => '/societe/class/societe.class.php', //'Categorie' => '/categories/class/categorie.class.php', 'ActionComm' => '/comm/action/class/actioncomm.class.php', @@ -241,7 +231,6 @@ 'Facture' => '/compta/facture/class/facture.class.php', 'FactureRec' => '/compta/facture/class/facture-rec.class.php', 'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php', - 'Mo' => '/mrp/class/mo.class.php', 'Contact' => '/contact/class/contact.class.php', 'Contrat' => '/contrat/class/contrat.class.php', 'Expedition' => '/expedition/class/expedition.class.php', @@ -250,11 +239,10 @@ 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php', 'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php', - 'Delivery' => '/delivery/class/delivery.class.php', + 'Livraison' => '/livraison/class/livraison.class.php', 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', - 'Ticket' => '/ticket/class/ticket.class.php', - 'User' => '/user/class/user.class.php' + 'User' => '/user/class/user.class.php', ); //First, all core objects must update their tables @@ -266,7 +254,6 @@ { $error++; setEventMessages($db->lasterror(), null, 'errors'); - break; } } } @@ -314,8 +301,10 @@ { setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs'); $db->commit(); - } else { - $langs->load("errors"); + } + else + { + $langs->load("errors"); setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors'); $db->rollback(); } @@ -323,160 +312,163 @@ } } - 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', '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->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); + 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); $object->oldcopy = clone $object; - } 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'); + } + 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'); // Incoterms if (!empty($conf->incoterm->enabled)) @@ -491,8 +483,8 @@ $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); } - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object); + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { $error++; @@ -506,58 +498,58 @@ } //var_dump($object->array_languages);exit; - 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 (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) { @@ -574,7 +566,7 @@ // Links with users $salesreps = GETPOST('commercial', 'array'); - $result = $object->setSalesRep($salesreps, true); + $result = $object->setSalesRep($salesreps); if ($result < 0) { $error++; @@ -599,112 +591,118 @@ setEventMessages($object->error, $object->errors, 'errors'); } - // 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) + // 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 { - 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; + 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)) - { - $duplicate_code_error = true; - $object->code_client = null; - } - - if ($result == -3 && in_array('ErrorSupplierCodeAlreadyUsed', $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 { $duplicate_code_error = true; $object->code_fournisseur = null; + $object->code_client = 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 (!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++; - } + 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++; + } // Links with users $salesreps = GETPOST('commercial', 'array'); @@ -737,163 +735,163 @@ } } - // 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) + // 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 { - 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 { + $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; + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $errors[] = "ErrorFileSizeTooLarge"; + break; + case 3: //uploaded file was only partially uploaded + $errors[] = "ErrorFilePartiallyUploaded"; + break; } - } - // Gestion du logo de la société - - - // Update linked member - if (!$error && $object->fk_soc > 0) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."adherent"; - $sql .= " SET fk_soc = NULL WHERE fk_soc = ".$id; - if (!$object->db->query($sql)) - { - $error++; - $object->error .= $object->db->lasterror(); - 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 third-party type - if ($action == 'set_thirdpartytype' && $user->rights->societe->creer) - { - $object->fetch($socid); - $result = $object->setThirdpartyType(GETPOST('typent_id', 'int')); - } - - // Set incoterm - if ($action == 'set_incoterms' && $user->rights->societe->creer && !empty($conf->incoterm->enabled)) - { - $object->fetch($socid); - $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } - - // Set parent company - if ($action == 'set_thirdparty' && $user->rights->societe->creer) - { - $object->fetch($socid); - $result = $object->set_parent(GETPOST('parent_id', 'int')); - } - - // Set sales representatives - if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) - { - $object->fetch($socid); - $result = $object->setSalesRep(GETPOST('commercial', 'array')); - } - - $id = $socid; - $object->fetch($socid); + } + // 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'; + 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 = $conf->societe->dir_output; - $permissiontoadd = $user->rights->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'; } @@ -908,7 +906,7 @@ if ($socid > 0 && empty($object->id)) { - $result = $object->fetch($socid); + $result = $object->fetch($socid); if ($result <= 0) dol_print_error('', $object->error); } @@ -921,172 +919,178 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { - // ----------------------------------------- - // When used with CANVAS - // ----------------------------------------- + // ----------------------------------------- + // When used with CANVAS + // ----------------------------------------- $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates - $objcanvas->display_canvas($action); // Show template -} else { - // ----------------------------------------- - // When used in standard mode - // ----------------------------------------- - if ($action == 'create') - { - /* + $objcanvas->display_canvas($action); // Show template +} +else +{ + // ----------------------------------------- + // When used in standard mode + // ----------------------------------------- + if ($action == 'create') + { + /* * Creation */ $private = GETPOST("private", "int"); if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !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 { + 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'); } - $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)) { + + $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)) { print "\n".''; - 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 ''; - 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 ''.$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 ''; - if ($conf->browser->layout == 'phone') print ''; - 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 ''; - } elseif ($mysoc->localtax1_assuj == "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 ''; - } elseif ($mysoc->localtax2_assuj == "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 ''; - } - - // Type - Workforce/Staff - 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, '', 1); - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; - if ($conf->browser->layout == 'phone') print ''; - 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); - print ''; - - // Legal Form - print ''.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; - print ''; - if ($object->country_id) - { - print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); - } else { - print $countrynotdefined; - } - print ''; - - // Capital - print ''.$form->editfieldkey('Capital', 'capital', '', $object, 0).''; - print ' '; - print ''.$langs->trans("Currency".$conf->currency).''; - - if (!empty($conf->global->MAIN_MULTILANGS)) - { - print ''.$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 ''; - print ''; - } + 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 ''; + + if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire)) + || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) + { + // Supplier + 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 ($conf->browser->layout == 'phone') print ''; + + 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 ''; + } + + // Status + print ''.$form->editfieldkey('Status', 'status', '', $object, 0).''; + print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1); + print ''; + + // Barcode + if (!empty($conf->barcode->enabled)) + { + print ''.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).''; + print ''; + print ''; + } + + // Address + print ''; + print $form->editfieldkey('Address', 'address', '', $object, 0); + print ''; + print ''; + print ''; + print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent'); + print ''; + + // Zip / Town + 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 ''; + if ($conf->browser->layout == 'phone') print ''; + 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 ''; + + // Country + 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 ''; + + // 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 ''.$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 ''; + } + + // Phone / Fax + print ''.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; + print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'.img_picto('', 'object_phoning').' '; + if ($conf->browser->layout == 'phone') print ''; + print ''.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + print 'browser->layout == 'phone' ? ' colspan="3"': '').'>'.img_picto('', 'object_phoning_fax').' '; + + // Email / Web + print ''.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', $conf->global->SOCIETE_EMAIL_MANDATORY).''; + print ''.img_picto('', 'object_email').' '; + print ''.$form->editfieldkey('Web', 'url', '', $object, 0).''; + print ''.img_picto('', 'globe').' '; + + if (!empty($conf->socialnetworks->enabled)) { + foreach ($socialnetworks as $key => $value) { + if ($value['active']) { + print ''; + print ''; + 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 ''.$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 ''; + if (($j % $NBCOLS) == ($NBCOLS - 1)) print ''; + $j++; + } + $i++; + } + if ($NBCOLS > 1 && ($j % 2 == 1)) print ''; + + // Vat is used + print ''.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).''; + print ''; + print $form->selectyesno('assujtva_value', GETPOSTISSET('assujtva_value') ?GETPOST('assujtva_value', 'int') : 1, 1); // Assujeti par defaut en creation + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).''; + print ''; + $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 ''; + 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 ''.$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 ''; + if ($conf->browser->layout == 'phone') print ''; + 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 ''; + } + elseif ($mysoc->localtax1_assuj == "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 ''; + } + elseif ($mysoc->localtax2_assuj == "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 ''; + } + + // Type - Size + 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 ''; + if ($conf->browser->layout == 'phone') print ''; + 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 ''; + + // Legal Form + print ''.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).''; + print ''; + if ($object->country_id) + { + print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code'); + } + else + { + print $countrynotdefined; + } + print ''; + + // Capital + print ''.$form->editfieldkey('Capital', 'capital', '', $object, 0).''; + print ' '; + print ''.$langs->trans("Currency".$conf->currency).''; + + if (!empty($conf->global->MAIN_MULTILANGS)) + { + print ''.$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 ''; + print ''; + } // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; print ''.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).''; - print ''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); + print ''; + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); print ''; } @@ -1513,17 +1528,17 @@ //if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { 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').$form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); print ""; //} // Supplier - if (!empty($conf->fournisseur->enabled)) { - 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').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); - print ""; - } + //if ($object->fournisseur) { + 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 ""; + //} } // Multicurrency @@ -1531,8 +1546,8 @@ { print ''; print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print ''; - print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); + print ''; + print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); print ''; } @@ -1544,135 +1559,139 @@ print ''; print ''.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; print ''; - $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1); + $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 img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('commercial', $userlist, $selected, null, null, null, null, "90%"); print ''; - // Ajout du logo - print ''; - print ''.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; - print ''; - print ''; - print ''; - print ''; - - print ''."\n"; - - print dol_get_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(); - } + // Ajout du logo + print ''; + print ''.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; + print ''; + print ''; + print ''; + 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(); + } $object->oldcopy = clone $object; - 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'); + 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'); //Incoterms if (!empty($conf->incoterm->enabled)) @@ -1681,33 +1700,33 @@ $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha'); } - //Local Taxes - $object->localtax1_assuj = GETPOST('localtax1assuj_value'); - $object->localtax2_assuj = GETPOST('localtax2assuj_value'); - - $object->localtax1_value = GETPOST('lt1'); - $object->localtax2_value = GETPOST('lt2'); - - // We set country_id, and country_code label of the chosen country - if ($object->country_id > 0) - { - $tmparray = getCountry($object->country_id, 'all'); - $object->country_code = $tmparray['code']; - $object->country = $tmparray['label']; - } - } - - if ($object->localtax1_assuj == 0) { - $sub = 0; - } else {$sub = 1; } - if ($object->localtax2_assuj == 0) { - $sub2 = 0; - } else {$sub2 = 1; } - - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; - } - - print '
'; - print ''; - print ''; - print ''; - print ''; - if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print ''; - - - print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); - - print '
'; - print ''; - - // Ref/ID + 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 ''; + 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 ''; - 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 - Workforce/Staff - 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 ''; - } + // 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)) @@ -2134,23 +2167,21 @@ foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - print img_picto('', 'category').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); print ""; // Supplier - if (!empty($conf->fournisseur->enabled)) { - print ''; - print '"; + print ''; + print '"; } // Multicurrency @@ -2158,8 +2189,8 @@ { print ''; print ''; - print ''; } @@ -2167,344 +2198,342 @@ $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); 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("ID").''; - print $object->ref; - 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, false, 0, 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, 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).''; - 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')); - 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 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 $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), '', 1); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - 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); - 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('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('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').$form->multiselectarray('suppcats', $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 $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print "
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); + print ''; + print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1); 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, 'AND u.statut = 1', 0, '', '', 0, 1); - $arrayselected = GETPOST('commercial', 'array'); - if (empty($arrayselected)) $arrayselected = $object->getSalesRepresentatives($user, 1); - print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1); - print '
'; - print '
'; - - print dol_get_fiche_end(); - - print '
'; - print ''; - print '     '; - print ''; - print '
'; - - print '
'; - } - } else { - /* + // Webservices url/key + if (!empty($conf->syncsupplierwebservices->enabled)) { + print ''.$form->editfieldkey('WebServiceURL', 'webservices_url', '', $object, 0).''; + print ''; + print ''.$form->editfieldkey('WebServiceKey', 'webservices_key', '', $object, 0).''; + print ''; + } + + // Logo + print ''; + print ''.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).''; + print ''; + if ($object->logo) print $form->showphoto('societe', $object); + $caneditfield = 1; + if ($caneditfield) + { + if ($object->logo) print "
\n"; + print ''; + if ($object->logo) print ''; + //print ''; + print ''; + print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; + } + print ''; + print ''; + + // Assign sale representative + print ''; + print ''.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).''; + print ''; + $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 ''; + 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); - - print dol_get_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($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 '
'.$langs->trans('ProspectCustomer').''; - print $object->getLibCustProspStatut(); - 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 ''; + } + + // 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 ''; - } - - // Customer code - if ($object->client) - { - 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 ''; + } } - print ''; - print ''; - } - - // Supplier code - if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire)) - { - print ''; + if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) + { + print ''; + print ''; + print ''; + print ''; + if ($action == 'editRE') { + print ''; + } else { + print ''; + } + print ''; + } } - 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 != '-') + elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") { - //if (($j % 2) == 0) print ''; - print ''; - print ''; - //if (($j % 2) == 1) print ''; - print ''; - $j++; + print ''; + if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) + { + print ''; + print ''; + print ''; + print ''; + if ($action == 'editIRPF') { + print ''; + } else { + print ''; + } + print ''; + } } - $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 ''; - } - } 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 ''; + } + + // Sale tax code (VAT code) + print ''; print ''; - - // Third-Party Type - print ''; - - // Workforce/Staff - print ''; - - print '
'.$langs->trans('ProspectCustomer').''; + print $object->getLibCustProspStatut(); + print '
'.$langs->trans('Supplier').''; - print yn($object->fournisseur); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$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 '
'; - print $langs->trans('CustomerCode').''; - print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; + } + + // Local Taxes + if ($object->fournisseur || $mysoc->country_code == 'ES') + { + if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") + { + 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.'
'; - print $langs->trans('SupplierCode').''; - print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; + elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") + { + print '
'.$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.'
'; - print $langs->trans('Gencod').''.dol_escape_htmltag($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 '
'.$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.'
'; - 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->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_escape_htmltag($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 '
'; - print ''; - if ($action != 'editthirdpartytype' && $user->rights->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.'
'; - print '
'; - - print '
'; - - print '
'; - print ''; - - // Tags / categories + 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 ''; + print ''; + + // Type + Staff + $arr = $formcompany->typent_array(1); + $object->typent = $arr[$object->typent_code]; + print ''; + 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 @@ -2516,7 +2545,7 @@ } // Supplier - if (!empty($conf->fournisseur->enabled) && $object->fournisseur) { + if ($object->fournisseur) { print ''; 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 ''; - } + // 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 ''; } @@ -2577,61 +2612,73 @@ $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 ''; - } - - // Sales representative - include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; - - // Module Adherent - if (!empty($conf->adherent->enabled)) - { - $langs->load("members"); - print ''; - print '\n"; - } - - // Webservices url/key - if (!empty($conf->syncsupplierwebservices->enabled)) { - print ''; - print ''; - } - - print '
'.$langs->trans("SuppliersCategoriesShort").''; print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1); @@ -2524,52 +2553,58 @@ } } - // Legal - 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 ''; - if ($action != 'editincoterm' && $user->rights->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 '
'.$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) : ''; + print ''; + print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code, 1) : ''; print '
'; - print ''; - if ($action != 'editparentcompany' && $user->rights->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, 's.rowid <> '.$object->id, 1); - print '
'.$langs->trans("LinkedToDolibarrMember").''; - $adh = new Adherent($db); - $result = $adh->fetch('', '', $object->id); - if ($result > 0) - { - $adh->ref = $adh->getFullName($langs); - print $adh->getNomUrl(1); - } else { - print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; - } - print "
'.$langs->trans("WebServiceURL").''.dol_print_url($object->webservices_url).''.$langs->trans('WebServiceKey').''.$object->webservices_key.'
'; + // 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 '
'; - - print dol_get_fiche_end(); - - - /* + print '
'; + print '
'; + + dol_fiche_end(); + + + /* * Actions */ - if ($action != 'presend') - { - print '
'."\n"; + if ($action != 'presend') + { + print '
'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -2650,50 +2697,54 @@ if (empty($user->socid)) { if (!empty($object->email) || $at_least_one_email_contact) + { + $langs->load("mails"); + print ''.$langs->trans('SendMail').''; + } + else { - $langs->load("mails"); - print ''.$langs->trans('SendMail').''; - } else { - $langs->load("mails"); - print ''.$langs->trans('SendMail').''; - } + $langs->load("mails"); + print ''.$langs->trans('SendMail').''; + } } - if ($user->rights->societe->creer) - { - print ''.$langs->trans("Modify").''."\n"; - } - - if (!empty($conf->adherent->enabled)) - { + if ($user->rights->societe->creer) + { + print ''.$langs->trans("Modify").''."\n"; + } + + if (!empty($conf->adherent->enabled)) + { $adh = new Adherent($db); $result = $adh->fetch('', '', $object->id); 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("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"; - } - } + print ''.$langs->trans('Delete').''."\n"; + } + } } - print '
'."\n"; - } - - //Select mail models is same action as presend + print '
'."\n"; + } + + //Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } @@ -2702,20 +2753,20 @@ { print '
'; - if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) - { + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) + { print ''; // ancre - /* + /* * Documents generes */ - $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; - $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; - $genallowed = $user->rights->societe->lire; - $delallowed = $user->rights->societe->creer; - - 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); - } + $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); + } // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) @@ -2727,7 +2778,7 @@ $MAXEVENT = 10; - $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id); + $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; @@ -2759,7 +2810,7 @@ $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - } + } } // End of page --- /tmp/dsg/dolibarr/htdocs/societe/github_consumption.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_consumption.php @@ -61,10 +61,10 @@ // Clean up on purge search criteria ? 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 = ''; + $sref = ''; + $sprod_fulldescr = ''; + $year = ''; + $month = ''; } // Customer or supplier selected in drop box $thirdTypeSelect = GETPOST("third_select_id"); @@ -107,7 +107,7 @@ } $head = societe_prepare_head($object); -print dol_get_fiche_head($head, 'consumption', $langs->trans("ThirdParty"), -1, 'company'); +dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -130,10 +130,7 @@ print ''; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; $resql = $db->query($sql); @@ -156,10 +153,7 @@ print ''; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; $resql = $db->query($sql); @@ -176,7 +170,7 @@ print '
'; -print dol_get_fiche_end(); +dol_fiche_end(); print '
'; @@ -259,16 +253,16 @@ } 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'; + 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. @@ -318,10 +312,10 @@ 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 .= ")"; + $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 .= ")"; } $sql .= $db->order($sortfield, $sortorder); @@ -336,8 +330,8 @@ $showempty = 2; if (empty($elementTypeArray) && !$object->client && !$object->fournisseur) { - $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); - $disabled = 1; + $showempty = $langs->trans("ThirdpartyNotCustomerNotSupplierSoNoRef"); + $disabled = 1; } // Define type of elements @@ -362,7 +356,7 @@ $num = $db->num_rows($resql); $param = "&socid=".urlencode($socid)."&type_element=".urlencode($type_element); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + 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); @@ -370,45 +364,45 @@ 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 ''; - 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"; + 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'); - $formother->select_year($year ? $year : -1, 'year', 1, 20, 1); - 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"; $i = 0; @@ -422,7 +416,6 @@ $documentstatic->statut = $objp->status; $documentstatic->status = $objp->status; $documentstatic->paye = $objp->paid; - $documentstatic->alreadypaid = $objp->paid; if (is_object($documentstaticline)) $documentstaticline->statut = $objp->status; @@ -434,17 +427,17 @@ // Status print ''; - // Label - print ''; } -// Address -if (!empty($arrayfields['s.address']['checked'])) -{ - print ''; -} // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -816,14 +795,14 @@ if (!empty($arrayfields['typent.code']['checked'])) { print ''; } // Staff if (!empty($arrayfields['staff.code']['checked'])) { print ''; } if (!empty($arrayfields['s.email']['checked'])) @@ -928,14 +907,14 @@ { $arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); } - print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); print ''; } if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -960,7 +939,7 @@ if (!empty($arrayfields['s.status']['checked'])) { print ''; } if (!empty($arrayfields['s.import_key']['checked'])) @@ -986,7 +965,6 @@ 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.address']['checked'])) print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $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); @@ -1053,7 +1031,7 @@ print ''; if (!empty($arrayfields['s.rowid']['checked'])) @@ -1067,16 +1045,18 @@ { $savalias = $obj->name_alias; if (!empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias = ''; - print 'global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').'>'; + print '\n"; $companystatic->name_alias = $savalias; - if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['s.name_alias']['checked'])) { @@ -1115,12 +1095,6 @@ print ''; if (!$i) $totalarray['nbfield']++; } - // Address - if (!empty($arrayfields['s.address']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -1148,7 +1122,7 @@ // Country if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; @@ -1222,7 +1196,6 @@ print "\n"; if (!$i) $totalarray['nbfield']++; } - // VAT if (!empty($arrayfields['s.tva_intra']['checked'])) { print "'; @@ -1269,13 +1250,13 @@ { // Prospect status print ''; if (!$i) $totalarray['nbfield']++; @@ -1283,14 +1264,14 @@ // Parent company if (!empty($arrayfields['s2.nom']['checked'])) { - print '"; - if (!$i) $totalarray['nbfield']++; + print '"; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -1328,7 +1309,7 @@ if (!$i) $totalarray['nbfield']++; } - // Action column (Show the massaction button only when this page is not opend from the Extended POS) + // Action column print ''; -} - $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); --- /tmp/dsg/dolibarr/htdocs/societe/github_note.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_note.php @@ -67,66 +67,64 @@ if ($object->id > 0) { - /* + /* * Affichage onglets */ - if (!empty($conf->notification->enabled)) $langs->load("mails"); + if (!empty($conf->notification->enabled)) $langs->load("mails"); - $head = societe_prepare_head($object); + $head = societe_prepare_head($object); - print dol_get_fiche_head($head, 'note', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'note', $langs->trans("ThirdParty"), -1, 'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - $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'; - print '
'; + print '
'; - print '
'; - 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 '
'; - if ($type_element == 'contract') { - print $documentstaticline->getLibStatut(5); - } elseif ($type_element == '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); } print ''; + print ''; // Define text, description and type $text = ''; $description = ''; $type = 0; @@ -481,7 +474,9 @@ } $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; - } else { + } + else + { $label = $objp->product_label; } @@ -515,23 +510,29 @@ $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); - } elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) + } + elseif ($objp->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); - } elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + } + elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) { $discount = new DiscountAbsolute($db); $discount->fetch($objp->fk_remise_except); echo ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); // Add date of deposit if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; - } else { + } + else + { echo ($txt ? ' - ' : '').dol_htmlentitiesbr($objp->description); } } - } else { + } + else + { if ($objp->fk_product > 0) { echo $form->textwithtooltip($text, $description, 3, '', '', $i, 0, ''); @@ -609,27 +610,29 @@ print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num); } $db->free($resql); -} elseif (empty($type_element) || $type_element == -1) -{ - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - - print ''."\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"; +} +elseif (empty($type_element) || $type_element == -1) +{ + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + + print '
'."\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 ''; print "
'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
"; -} else { - print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); - - print ''."\n"; +} +else { + print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', ''); + + print '
'."\n"; print ''; --- /tmp/dsg/dolibarr/htdocs/societe/github_contact.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_contact.php @@ -68,7 +68,7 @@ // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycontact', 'globalcard')); -if ($object->fetch($socid) <= 0 && $action == 'view') +if ($action == 'view' && $object->fetch($socid) <= 0) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); @@ -76,18 +76,21 @@ } // Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$object->getCanvas($socid); $canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); $objcanvas = null; if (!empty($canvas)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; - $objcanvas = new Canvas($db, $action); - $objcanvas->getCanvas('thirdparty', 'card', $canvas); + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('thirdparty', 'card', $canvas); } // Security check -$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); if (empty($user->rights->societe->contact->lire)) accessforbidden(); + + /* @@ -101,17 +104,17 @@ if (empty($reshook)) { if ($cancel) - { - $action = ''; - if (!empty($backtopage)) - { - header("Location: ".$backtopage); - exit; - } - } + { + $action = ''; + if (!empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + } - // 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'; } @@ -126,7 +129,7 @@ if ($socid > 0 && empty($object->id)) { - $result = $object->fetch($socid); + $result = $object->fetch($socid); if ($result <= 0) dol_print_error('', $object->error); } @@ -144,13 +147,13 @@ $head = societe_prepare_head($object); -print dol_get_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); +dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); -print dol_get_fiche_end(); +dol_fiche_end(); print '
'; --- /tmp/dsg/dolibarr/htdocs/societe/github_document.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_document.php @@ -105,7 +105,7 @@ $form = new Form($db); - print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company'); // Build file list @@ -116,13 +116,13 @@ $totalsize += $file['size']; } - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; print '
'.$langs->trans("FeatureNotYetAvailable").'
'; // Prefix @@ -136,10 +136,7 @@ print ''; } @@ -148,10 +145,7 @@ print ''; } @@ -165,14 +159,16 @@ print ''; - print dol_get_fiche_end(); + 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'; -} else { +} +else +{ accessforbidden('', 0, 0); } --- /tmp/dsg/dolibarr/htdocs/societe/github_index.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_index.php @@ -58,6 +58,8 @@ print load_fiche_titre($transAreaType, $linkback, 'companies'); +//print '
'; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'; +//print '
'; print '
'; @@ -84,30 +86,31 @@ $result = $db->query($sql); 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); + 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 (!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 ''."\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 ''; + // Name + print '\n"; + // Type + print ''; + // Last modified date + print '"; + print '"; + print "\n"; + $i++; + } + + $db->free($result); + + print "
'.$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(); + print '
'; + $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(); $dolgraph->SetData($dataseries); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); @@ -115,28 +118,30 @@ $dolgraph->setHeight('200'); $dolgraph->draw('idgraphthirdparties'); print $dolgraph->show(); - print '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$langs->trans("UniqueThirdParties").''; print $total; @@ -180,7 +185,9 @@ if ($i < $nbmax) { $dataseries[] = array($obj->label, round($obj->nb)); - } else { + } + else + { $rest += $obj->nb; } $total += $obj->nb; @@ -199,7 +206,9 @@ $dolgraph->setHeight('200'); $dolgraph->draw('idgraphcateg'); print $dolgraph->show(); - } else { + } + else + { while ($i < $num) { $obj = $db->fetch_object($result); @@ -218,6 +227,7 @@ print ''; } +//print ''; print '
'; @@ -246,86 +256,91 @@ $result = $db->query($sql); if ($result) { - $num = $db->num_rows($result); - - $i = 0; - - if ($num > 0) - { - $transRecordedType = $langs->trans("LastModifiedThirdParties", $max); - - print "\n\n"; - print '
'; - print ''; - - 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; + $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; $thirdparty_static->entity = $objp->entity; - $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; - $thirdparty_static->code_compta = $objp->code_compta; - - print ''; - // Name - print '\n"; - // Type - print ''; - // Last modified date - print '"; - print '"; - print "\n"; - $i++; - } - - $db->free($result); - - print "
'.$transRecordedType.' '.$langs->trans("FullList").'
'; - print $thirdparty_static->getNomUrl(1); - print "'; - $obj = $thirdparty_static; - $s = ''; - if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { - $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; - } - if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; - } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) - { - $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; - } - print $s; - 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); -} - + $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 ''; $parameters = array('user' => $user); --- /tmp/dsg/dolibarr/htdocs/societe/github_list.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_list.php @@ -10,7 +10,6 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2017 Juanjo Menent * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2020 Open-Dsi * * This program is free software; you can redistribute it and/or modify @@ -43,7 +42,7 @@ $langs->loadLangs(array("companies", "commercial", "customers", "suppliers", "bills", "compta", "categories", "cashdesk")); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); @@ -52,7 +51,7 @@ if ($contextpage == 'poslist') { - $_GET['optioncss'] = 'print'; + $_GET['optioncss'] = 'print'; } // Security check @@ -64,15 +63,14 @@ $search_cti = preg_replace('/^0+/', '', preg_replace('/[^0-9]/', '', GETPOST('search_cti', 'alphanohtml'))); // Phone number without any special chars $search_id = trim(GETPOST("search_id", "int")); -$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')); $search_barcode = trim(GETPOST("search_barcode", 'alpha')); $search_customer_code = trim(GETPOST('search_customer_code', 'alpha')); $search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha')); $search_account_customer_code = trim(GETPOST('search_account_customer_code', 'alpha')); $search_account_supplier_code = trim(GETPOST('search_account_supplier_code', 'alpha')); -$search_address = trim(GETPOST('search_address', 'alpha')); $search_town = trim(GETPOST("search_town", 'alpha')); $search_zip = trim(GETPOST("search_zip", 'alpha')); $search_state = trim(GETPOST("search_state", 'alpha')); @@ -121,7 +119,6 @@ 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 object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -142,8 +139,6 @@ 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"CustomerAccountancyCodeShort", 's.code_compta_fournisseur'=>"SupplierAccountancyCodeShort", - 's.zip'=>"Zip", - 's.town'=>"Town", 's.email'=>"EMail", 's.url'=>"URL", 's.tva_intra'=>"VATIntra", @@ -187,8 +182,7 @@ '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))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode), '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.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0), - 's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>0), + 's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'position'=>21, 'checked'=>1), 'state.nom'=>array('label'=>"State", 'position'=>22, 'checked'=>0), 'region.nom'=>array('label'=>"Region", 'position'=>23, 'checked'=>0), @@ -216,8 +210,14 @@ 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -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])); + } +} $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -228,9 +228,9 @@ if ($action == "change") // Change customer for TakePOS { - $idcustomer = GETPOST('idcustomer', 'int'); - - // Check if draft invoice already exists, if not create it + $idcustomer = GETPOST('idcustomer', 'int'); + + // Check if draft invoice already exists, if not create it $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")' AND entity IN (".getEntity('invoice').")"; $result = $db->query($sql); $num_lines = $db->num_rows($result); @@ -248,9 +248,9 @@ $db->query($sql); } - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; - $resql = $db->query($sql); - ?> + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + ?> code) $level = $langs->trans($obj->label); $tab_level[$obj->code] = $level; } -} else dol_print_error($db); - -$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,"; $sql .= " s.entity,"; -$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,"; $sql .= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; $sql .= " s.tms as date_update, s.datec as date_creation,"; $sql .= " s.code_compta, s.code_compta_fournisseur, s.parent as fk_parent,"; @@ -431,6 +431,7 @@ elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; 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"; @@ -451,12 +452,11 @@ 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 ($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->sanitize($db->escape($search_country)).')'; +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); @@ -469,7 +469,7 @@ if (strlen($search_idprof6)) $sql .= natural_search("s.idprof6", $search_idprof6); if (strlen($search_vat)) $sql .= natural_search("s.tva_intra", $search_vat); // Filter on type of thirdparty -if ($search_type > 0 && in_array($search_type, array('1,3', '1,2,3', '2,3'))) $sql .= " AND s.client IN (".$db->sanitize($db->escape($search_type)).")"; +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); @@ -482,12 +482,10 @@ if ($search_import_key) $sql .= natural_search("s.import_key", $search_import_key); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + // Add where from hooks -$parameters = array('socid' => $socid); +$parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - if ($socid) $sql .= " AND s.rowid = ".$socid; -} $sql .= $hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); @@ -519,21 +517,21 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); 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; + $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'; @@ -549,7 +547,6 @@ 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_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); @@ -598,31 +595,21 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$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' && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES) || !empty($conf->global->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 = dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', $url, '', $user->rights->societe->creer); -} elseif ($user->rights->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); +$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 '
'; @@ -665,7 +652,7 @@ $moreforfilter = ''; if (empty($type) || $type == 'c' || $type == 'p') { - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) + if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; @@ -676,7 +663,7 @@ } if (empty($type) || $type == 'f') { - if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) + if (!empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; @@ -706,7 +693,6 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -// Show the massaction checkboxes only when this page is not opend from the Extended POS if ($massactionbutton && $contextpage != 'poslist') $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); if (empty($arrayfields['customerorsupplier']['checked'])) print ''; @@ -770,13 +756,6 @@ print ''; print '
'; - print ''; - print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth75', 1); + 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)); print ''; - print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100', 1); + print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100'); print ''; - print ''; - print ''; + print ''; + print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 1); print '
'; if ($contextpage == 'poslist') { - print $obj->name; - } else { - print $companystatic->getNomUrl(1, '', 100, 0, 1); + print $obj->name; + } + else + { + print $companystatic->getNomUrl(1, '', 100, 0, 1); } print "'.$obj->code_compta_fournisseur.''.$obj->address.''; + print ''; $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 '".$obj->idprof6.""; @@ -1239,17 +1212,25 @@ { 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); + } if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - $s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).''; - } - if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; + if ($s) $s .= ", "; + $companystatic->name = $langs->trans("Prospect"); + $companystatic->name_alias = ''; + $s .= $companystatic->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)) && $obj->fournisseur) { - $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; + if ($s) $s .= ", "; + $companystatic->name = $langs->trans("Supplier"); + $companystatic->name_alias = ''; + $s .= $companystatic->getNomUrl(0, 'supplier', 0, 1); } print $s; print '
'; - print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + 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'], $val['picto']).''; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code']).''; } print '
'; - if ($companystatic->fk_parent > 0) - { - $companyparent->fetch($companystatic->fk_parent); - print $companyparent->getNomUrl(1); - } - print "'; + if ($companystatic->fk_parent > 0) + { + $companyparent->fetch($companystatic->fk_parent); + print $companyparent->getNomUrl(1); + } + 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 { @@ -1343,14 +1324,6 @@ $i++; } -// If no record found -if ($num == 0) -{ - $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } - print '
'.$langs->trans("NoRecordFound").'
'; + print '
'; + print '
'; - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } - if ($object->client) { + if ($object->client) + { print ''; } - if ($object->fournisseur) { + if ($object->fournisseur) + { print ''; } - print "
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
"; + print ""; - print '
'; + print '
'; - //print '
'; + //print '
'; - //print '
'; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + //print '
'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - print dol_get_fiche_end(); -} else { + dol_fiche_end(); +} +else +{ $langs->load("errors"); print $langs->trans("ErrorRecordNotFound"); } --- /tmp/dsg/dolibarr/htdocs/societe/github_paymentmodes.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_paymentmodes.php @@ -175,7 +175,9 @@ if (!$result) { setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); - } else { + } + else + { // If this account is the default bank account, we disable others if ($companybankaccount->default_rib) { @@ -228,7 +230,9 @@ if (!$result) { setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); - } else { + } + else + { // If this account is the default bank account, we disable others if ($companypaymentmode->default_rib) { @@ -334,7 +338,9 @@ $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; - } else { + } + else + { $db->rollback(); } } @@ -401,7 +407,9 @@ $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; header('Location: '.$url); exit; - } else { + } + else + { $db->rollback(); } } @@ -416,7 +424,9 @@ $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; - } else { + } + else + { setEventMessages($db->lasterror, null, 'errors'); } } @@ -441,10 +451,14 @@ $url = $_SERVER['PHP_SELF']."?socid=".$object->id; header('Location: '.$url); exit; - } else { + } + else + { setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); } - } else { + } + else + { setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); } } @@ -459,10 +473,14 @@ $url = $_SERVER['PHP_SELF']."?socid=".$object->id; header('Location: '.$url); exit; - } else { + } + else + { setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); } - } else { + } + else + { setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); } } @@ -497,14 +515,18 @@ { $error++; setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors'); - } else { + } + else + { // Creation of Stripe customer + update of societe_account $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); if (!$cu) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); - } else { + } + else + { $stripecu = $cu->id; } } @@ -518,7 +540,9 @@ { $error++; setEventMessages('ThisPaymentModeIsNotACard', null, 'errors'); - } else { + } + else + { // Get the Stripe customer $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (!$cu) @@ -550,12 +574,12 @@ $db->begin(); - 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($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 = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." 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 ! + } $resql = $db->query($sql); $num = $db->num_rows($resql); // Note: $num is always 0 on an update and delete, it is defined for select only. @@ -577,8 +601,8 @@ } } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; - $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."', site_account = '".$db->escape($site_account)."'"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '' or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND status = ".$servicestatus." 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 ! $resql = $db->query($sql); } } @@ -588,7 +612,9 @@ { $stripecu = $newcu; $db->commit(); - } else { + } + else + { $db->rollback(); } } @@ -601,21 +627,21 @@ $db->begin(); - if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$db->escape($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 = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND service = '".$db->escape($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 = '".$db->escape(json_encode($tokenstring))."'"; - $sql .= " WHERE site = 'stripe' AND (site_account IS NULL or site_account = '".$db->escape($site_account)."') AND fk_soc = ".$object->id." AND service = '".$db->escape($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 = '".$db->escape($service)."' 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) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } @@ -625,14 +651,14 @@ $num = $db->num_rows($resql); 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 ('".$db->escape($service)."', ".$object->id.", ".$conf->entity.", '".$db->escape(json_encode($tokenstring))."')"; - // TODO Add site and site_account on oauth_token table - } catch (Exception $e) { + 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) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } @@ -643,7 +669,9 @@ { $stripesupplieracc = $newsup; $db->commit(); - } else { + } + else + { $db->rollback(); } } @@ -656,19 +684,23 @@ $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; - } catch (Exception $e) + } + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only + } + elseif ($action == 'setassourcedefault') // Set as default when payment mode defined remotely only { try { $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); if (preg_match('/pm_/', $source)) { $cu->invoice_settings->default_payment_method = (string) $source; // New - } else { + } + else + { $cu->default_source = (string) $source; // Old } $result = $cu->save(); @@ -676,38 +708,43 @@ $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; - } catch (Exception $e) + } + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } - } elseif ($action == 'deletecard' && $source) + } + elseif ($action == 'deletecard' && $source) { 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')) { + $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(); } else { $card->delete(); } - } + } } $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; header('Location: '.$url); exit; - } catch (Exception $e) + } + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); @@ -745,7 +782,9 @@ { $companybankaccount->fetch(0, $object->id); $companypaymentmode->fetch(0, null, $object->id, 'card'); -} else { +} +else +{ $companybankaccount->fetch($id); $companypaymentmode->fetch($id); } @@ -773,7 +812,7 @@ // View if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard') { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); // Confirm delete ban if ($action == 'delete') @@ -808,10 +847,7 @@ print ''; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; $resql = $db->query($sql); @@ -835,7 +871,7 @@ print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); if (!empty($conf->stripe->enabled) && $stripecu && $action != 'editkey_account') { - $connect = ''; + $connect = ''; if (!empty($stripeacc)) $connect = $stripeacc.'/'; $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; if ($servicestatus) @@ -851,22 +887,19 @@ print ''; print ''; print ''; - print ''; + print ''; print ''; } 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").')'; - } + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print ''; $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; $resql = $db->query($sql); @@ -892,7 +925,7 @@ 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 = ''; + $connect = ''; $url = 'https://dashboard.stripe.com/test/connect/accounts/'.$stripesupplieracc; if ($servicestatus) @@ -909,7 +942,7 @@ print ''; print ''; print ''; - //print ''; + //print ''; print ''; } print ''; @@ -918,7 +951,7 @@ print ''; print ''; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; @@ -928,7 +961,7 @@ $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'); + $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'); @@ -942,7 +975,9 @@ if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { $listofsources = $customerstripe->sources->data; - } else { + } + else + { $service = 'StripeTest'; $servicestatus = 0; if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) @@ -963,14 +998,16 @@ } $listofsources = $paymentmethodobjs->data; - } catch (Exception $e) + } + catch (Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } } } - } catch (Exception $e) + } + catch (Exception $e) { dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); } @@ -1044,9 +1081,9 @@ 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; + $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; @@ -1067,13 +1104,14 @@ $img = picto_from_langcode($companypaymentmodetemp->country_code); print $img ? $img.' ' : ''; print getCountry($companypaymentmodetemp->country_code, 1); - } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; print ''; // Default print ''; if (empty($companypaymentmodetemp->default_rib)) { - print ''; + print ''; print img_picto($langs->trans("Default"), 'off'); print ''; } else { @@ -1100,11 +1138,11 @@ print ''.$langs->trans("CreateCardOnStripe").''; } - print ''; + print ''; print img_picto($langs->trans("Modify"), 'edit'); print ''; print ' '; - print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& + print ''; // source='.$companypaymentmodetemp->stripe_card_ref.'& print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1114,7 +1152,8 @@ $i++; } } - } else dol_print_error($db); + } + else dol_print_error($db); } // Show remote sources (not already shown as local source) @@ -1144,8 +1183,8 @@ $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; + //$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 ''; @@ -1154,16 +1193,20 @@ if ($src->object == 'card') { print img_credit_card($src->brand); - } elseif ($src->object == 'source' && $src->type == 'card') + } + elseif ($src->object == 'source' && $src->type == 'card') { print img_credit_card($src->card->brand); - } elseif ($src->object == 'source' && $src->type == 'sepa_debit') + } + elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print ''; - } elseif ($src->object == 'payment_method' && $src->type == 'card') + } + elseif ($src->object == 'payment_method' && $src->type == 'card') { print img_credit_card($src->card->brand); - } elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') + } + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { print ''; } @@ -1179,8 +1222,10 @@ $img = picto_from_langcode($src->country); print $img ? $img.' ' : ''; print getCountry($src->country, 1); - } else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; - } elseif ($src->object == 'source' && $src->type == 'card') + } + 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.''; print ''; @@ -1190,8 +1235,10 @@ $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 == 'source' && $src->type == 'sepa_debit') + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + elseif ($src->object == 'source' && $src->type == 'sepa_debit') { print 'SEPA debit'; print ''; @@ -1200,8 +1247,10 @@ $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') + } + 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 ''; @@ -1211,8 +1260,10 @@ $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') + } + else print img_warning().' '.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).''; + } + elseif ($src->object == 'payment_method' && $src->type == 'sepa_debit') { print 'SEPA debit'; print ''; @@ -1221,8 +1272,10 @@ $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 { print ''; } print ''; @@ -1231,7 +1284,7 @@ if ((empty($customerstripe->invoice_settings) && $customerstripe->default_source != $src->id) || (!empty($customerstripe->invoice_settings) && $customerstripe->invoice_settings->default_payment_method != $src->id)) { - print ''; + print ''; print img_picto($langs->trans("Default"), 'off'); print ''; } else { @@ -1254,7 +1307,7 @@ print ''; if ($user->rights->societe->creer) { - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1272,30 +1325,30 @@ } print ""; print ""; - print '
'; + print '
'; } // List of Stripe payment modes - if (!empty($conf->stripe->enabled) && !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)); + 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)); print ''."\n"; print ''; print ''; print ''; print ''; - print ''; - print ''; - - $currencybalance = array(); + print ''; + 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; + $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; } else { $currencybalance[$cpt->currency]['available'] = $cpt->amount; } @@ -1303,7 +1356,7 @@ } } - if (is_array($balance->pending) && count($balance->pending)) + if (is_array($balance->pending) && count($balance->pending)) { foreach ($balance->pending as $cpt) { @@ -1314,7 +1367,7 @@ $currencybalance[$cpt->currency]['pending'] = $currencybalance[$cpt->currency]['available'] + $cpt->amount; } } - } + } if (is_array($currencybalance)) { @@ -1324,13 +1377,13 @@ } } - print '
'.$langs->trans('Currency').''.$langs->trans('Available').''.$langs->trans('Pending').''.$langs->trans('Total').'
'.$langs->trans('Total').'
'; - print '
'; + print ''; + print '
'; } // List of bank accounts - $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'); print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank'); @@ -1377,11 +1430,11 @@ } elseif ($val == 'BankAccountNumberKey') { $string .= $rib->cle_rib.' '; } - // 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.' ';*/ //} } if (!empty($rib->label) && $rib->number) { @@ -1426,7 +1479,7 @@ // Default print ''; if (!$rib->default_rib) { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'off'); print ''; } else { @@ -1498,7 +1551,7 @@ print img_picto($langs->trans("Modify"), 'edit'); print ''; - print ''; + print ''; print img_picto($langs->trans("Delete"), 'delete'); print ''; } @@ -1536,7 +1589,7 @@ $genallowed = $user->rights->societe->lire; $delallowed = $user->rights->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); + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) @@ -1587,7 +1640,7 @@ // Edit BAN if ($socid && $action == 'edit' && $user->rights->societe->creer) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1692,19 +1745,19 @@ } - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; } // Edit Card if ($socid && $action == 'editcard' && $user->rights->societe->creer) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1739,12 +1792,12 @@ print ''; print ''; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; } @@ -1752,7 +1805,7 @@ // Create BAN if ($socid && $action == 'create' && $user->rights->societe->creer) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1853,21 +1906,21 @@ print ''; - print dol_get_fiche_end(); + dol_fiche_end(); dol_set_focus('#label'); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; } // Create Card if ($socid && $action == 'createcard' && $user->rights->societe->creer) { - print dol_get_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -1903,14 +1956,14 @@ print ''; - print dol_get_fiche_end(); + dol_fiche_end(); dol_set_focus('#label'); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; } --- /tmp/dsg/dolibarr/htdocs/societe/github_price.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_price.php @@ -40,12 +40,9 @@ $langs->loadLangs(array("products", "companies", "bills")); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $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'); // Security check $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); @@ -71,112 +68,112 @@ 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->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 = '".$db->escape($mysoc->country_code)."'"; - $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; - $sql .= " AND t.code ='".$db->escape($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 = ''; - } + 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 = ''; + } } @@ -195,7 +192,7 @@ $langs->load("mails"); $head = societe_prepare_head($object); -print dol_get_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); +dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -215,10 +212,8 @@ print ''; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { + if ($object->check_codeclient() != 0) print ' ('.$langs->trans("WrongCustomerCode").')'; - } print ''; } @@ -226,10 +221,8 @@ print ''; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { + if ($object->check_codefournisseur() != 0) print ' ('.$langs->trans("WrongSupplierCode").')'; - } print ''; } @@ -237,7 +230,7 @@ print ''; -print dol_get_fiche_end(); +dol_fiche_end(); @@ -246,7 +239,7 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); - $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $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; @@ -266,18 +259,6 @@ $filter ['prod.ref'] = $search_prod; } - 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; - } - if ($action == 'add_customer_price') { // Create mode @@ -347,9 +328,9 @@ print ''; print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print '
'; @@ -426,14 +407,14 @@ print ''; print '
'; - print ''; + print ''; print '     '; - print ''; + print ''; print '
'; print '
'; } elseif ($action == 'showlog_customer_price') { - print '
'; + print '
'; print ''."\n"; $filter = array( @@ -499,15 +480,19 @@ print ''; } print ""; - } else { + } + else + { print $langs->trans('None'); } print "\n".'
'."\n"; print '
'.$langs->trans("Ok").'
'; print "\n

\n"; - } else { - // View mode + } + else + { + // View mode /* ************************************************************************** */ /* */ @@ -523,118 +508,114 @@ print "\n\n"; - // 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.'&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 ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - if (count($prodcustprice->lines) > 0 || $search_prod) - { - 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 '
'.$langs->trans("Ref").''.$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").' 
'; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if (count($prodcustprice->lines) > 0 || $search_prod) + { + print ''; print ''; - print ''; - print ''; - 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 ''; - 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)."".$staticprod->label."".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 "
"; + print ' '; + // Print the search button + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print ''; + print ''; + } + + if (count($prodcustprice->lines) > 0) + { + foreach ($prodcustprice->lines as $line) + { + print ''; + + $staticprod = new Product($db); + $staticprod->fetch($line->fk_product); + + print "".$staticprod->getNomUrl(1).""; + print "".dol_print_date($line->datec, "dayhour").""; + + print ''.$langs->trans($line->price_base_type).""; + print ''.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly).""; + print ''.price($line->price).""; + print ''.price($line->price_ttc).""; + print ''.price($line->price_min).''; + print ''.price($line->price_min_ttc).''; + + // User + $userstatic = new User($db); + $userstatic->fetch($line->fk_user); + print ''; + print $userstatic->getLoginUrl(1); + print ''; + + // Action + if ($user->rights->produit->creer || $user->rights->service->creer) + { + 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 ''; + } + + print "\n"; + } + } + else + { + $colspan = 9; + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1; + print ''.$langs->trans('None').''; + } + + print ""; + + print ""; } } --- /tmp/dsg/dolibarr/htdocs/societe/github_project.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_project.php @@ -78,31 +78,28 @@ if (!empty($conf->notification->enabled)) $langs->load("mails"); $head = societe_prepare_head($object); - print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); - print '
'; + print '
'; - print '
'; + print '
'; print ''; - if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field + { + print ''; + } if ($object->client) { print ''; } @@ -111,10 +108,7 @@ print ''; } @@ -122,17 +116,17 @@ print ''; - print dol_get_fiche_end(); + dol_fiche_end(); $params = ''; $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 '
'; + print '
'; // Projects list - $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); + $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); } // End of page --- /tmp/dsg/dolibarr/htdocs/societe/github_societecontact.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_societecontact.php @@ -36,7 +36,7 @@ $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -68,23 +68,26 @@ { $result = $object->fetch($id); - 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 && $id > 0) + { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } else { + } + else + { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = '
'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
'; - } else { + } + else + { $mesg = '
'.$object->error.'
'; } } @@ -95,8 +98,10 @@ { if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne')); - } else { + $result = $object->swapContactStatus(GETPOST('ligne')); + } + else + { dol_print_error($db); } } @@ -111,7 +116,8 @@ { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; - } else { + } + else { dol_print_error($db); } } @@ -153,22 +159,22 @@ $soc->fetch($object->socid); $head = societe_prepare_head($object); - print dol_get_fiche_head($head, 'contact', $langs->trans("ThirdParty"), -1, 'company'); + dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), -1, 'company'); print ''; print ''; - $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 '
'; print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'; - // Prospect/Customer - /*print ''; @@ -179,7 +185,7 @@ if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { - print ''; + print ''; } if ($object->client) @@ -187,10 +193,7 @@ print ''; } @@ -199,10 +202,7 @@ print ''; } print '
'.$langs->trans('ProspectCustomer').''; + // Prospect/Customer + /*print '
'.$langs->trans('ProspectCustomer').''; print $object->getLibCustProspStatut(); print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongCustomerCode").')'; - } + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { - print ' ('.$langs->trans("WrongSupplierCode").')'; - } + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'; @@ -327,13 +327,17 @@ print " ".img_warning($langs->trans("SubscriptionLate")); } print ''; - } else { + } + else + { print ''; if ($objp->subscription == 'yes') { print $langs->trans("SubscriptionNotReceived"); if ($objp->statut > 0) print " ".img_warning(); - } else { + } + else + { print ' '; } print ''; @@ -346,7 +350,9 @@ } } } - } else { + } + else + { // Contrat non trouve print "ErrorRecordNotFound"; } --- /tmp/dsg/dolibarr/htdocs/societe/github_website.php +++ /tmp/dsg/dolibarr/htdocs/societe/client_website.php @@ -39,7 +39,7 @@ $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 +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // 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') @@ -76,7 +76,7 @@ unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); $search = array(); foreach ($objectwebsiteaccount->fields as $key => $val) { @@ -99,8 +99,14 @@ } // Extra fields -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])); + } +} $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -121,39 +127,39 @@ 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'; + // 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'; } @@ -185,7 +191,7 @@ $head = societe_prepare_head($object); -print dol_get_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company'); +dol_fiche_head($head, 'website', $langs->trans("ThirdParty"), - 1, 'company'); $linkback = ''.$langs->trans("BackToList").''; @@ -207,10 +213,8 @@ print ''; print $langs->trans('CustomerCode').''; print $object->code_client; - $tmpcheck = $object->check_codeclient(); - if ($tmpcheck != 0 && $tmpcheck != -5) { + if ($object->check_codeclient() != 0) print ' ('.$langs->trans("WrongCustomerCode").')'; - } print ''; } @@ -218,10 +222,8 @@ print ''; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; - $tmpcheck = $object->check_codefournisseur(); - if ($tmpcheck != 0 && $tmpcheck != -5) { + if ($object->check_codefournisseur() != 0) print ' ('.$langs->trans("WrongSupplierCode").')'; - } print ''; } @@ -229,14 +231,14 @@ print '
'; -print dol_get_fiche_end(); +dol_fiche_end(); $newcardbutton = ''; if (!empty($conf->website->enabled)) { if (!empty($user->rights->societe->lire)) { $newcardbutton .= dolGetButtonTitle($langs->trans("AddWebsiteAccount"), '', '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)); - } 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); } }