diff --git a/dev/initdata/generate-product.php b/dev/initdata/generate-product.php index e9703fbfd6e..83951c57df7 100755 --- a/dev/initdata/generate-product.php +++ b/dev/initdata/generate-product.php @@ -61,8 +61,8 @@ $user->getrights(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array(); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } + $num = $db->num_rows($resql); $i = 0; + while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array(); diff --git a/dev/initdata/generate-thirdparty.php b/dev/initdata/generate-thirdparty.php index f1e0f4f360b..9f740b5705d 100755 --- a/dev/initdata/generate-thirdparty.php +++ b/dev/initdata/generate-thirdparty.php @@ -64,22 +64,34 @@ $user->getrights(); $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array(); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; } + $num = $db->num_rows($resql); $i = 0; + while ($i < $num) { + $row = $db->fetch_row($resql); + $productsid[$i] = $row[0]; + $i++; + } } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array(); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; } + while ($i < $num) { + $row = $db->fetch_row($resql); + $societesid[$i] = $row[0]; + $i++; + } } else { print "err"; } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array(); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; } + while ($i < $num) { + $row = $db->fetch_row($resql); + $commandesid[$i] = $row[0]; + $i++; + } } else { print "err"; } diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 8c01eea6d99..015733ed95f 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -186,7 +186,7 @@ - + diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 7f095a744db..f568ba2b04b 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -149,9 +149,9 @@ foreach ($langstrings_3d AS $filename => $file) $keys = array_keys($langstrings_full, $value); if (count($keys)>1) { - foreach ($keys AS $key) { - $dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]); - } + foreach ($keys AS $key) { + $dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]); + } } } } diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index ead5e767243..97392b902bc 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,7 +178,7 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) $listofval = array(-1 => $langs->trans("Undefined")); $listofval += $adht->liste_array(); $forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1; - print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listetype)>1?1:0); + print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0); print "\n"; // Amount diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 3ac400509c9..e9b1a5e4de8 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2177,6 +2177,10 @@ class Adherent extends CommonObject global $langs; $langs->load("members"); + $statusType = ''; + $labelstatut = ''; + $labelstatutShort = ''; + if ($statut == -1) { $statusType = 'status0'; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index f8f21d2868a..3f3c77568c2 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -140,6 +140,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
'; print ''; + print '
'; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -152,6 +153,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print '
'; print '
'; } diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index de9d1677932..c39cc385313 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -214,15 +214,17 @@ asort($orders); //var_dump($modules); +unset($objMod); $i=0; foreach($orders as $tmpkey => $tmpvalue) { - $objMod = $modules[$tmpkey]; - if ($objMod->numero == $id) + $tmpMod = $modules[$tmpkey]; + if ($tmpMod->numero == $id) { $key = $i; $modName = $filename[$tmpkey]; $dirofmodule = $dirmod[$tmpkey]; + $objMod = $tmpMod; break; } $i++; @@ -233,25 +235,7 @@ $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$ -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc'; -$head[$h][1] = $langs->trans("Description"); -$head[$h][2] = 'desc'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature'; -$head[$h][1] = $langs->trans("TechnicalServicesProvided"); -$head[$h][2] = 'feature'; -$h++; - -if ($objMod->isCoreOrExternalModule() == 'external') -{ - $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=changelog'; - $head[$h][1] = $langs->trans("ChangeLog"); - $head[$h][2] = 'changelog'; - $h++; -} +$head = modulehelp_prepare_head($objMod); // Check filters $modulename=$objMod->getName(); diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index abcb3145a80..2a5758e61d2 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -70,7 +70,7 @@ function printBookmarksList() $ret.= ' - '.$top_liste_produits.''."\n"; +'.$top_liste_produits.''."\n"; - $id = $obj_facturation->id(); +$id = $obj_facturation->id(); - // Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ... +// Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ... - $nbtoshow = $nbr_enreg; - if (! empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes; +$nbtoshow = $nbr_enreg; +if (! empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) $nbtoshow = $conf_taille_listes; - for ($i = 0; $i < $nbtoshow; $i++) - { - if ( $id == $tab_designations[$i]['rowid'] ) - $selected = 'selected'; - else - $selected = ''; +for ($i = 0; $i < $nbtoshow; $i++) +{ + if ($id == $tab_designations[$i]['rowid']) { + $selected = 'selected'; + } else { + $selected = ''; + } - $label = $tab_designations[$i]['label']; + $label = $tab_designations[$i]['label']; - print ''."\n"; - } - ?> + print ''."\n"; +} +?> diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index cb7b7dd2f10..813364d18a5 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -85,7 +85,7 @@ $object->fetch($facid); for($i=0;$i < $tab_size;$i++) { $remise = $tab[$i]['remise']; - ?> + ?> @@ -93,7 +93,7 @@ $object->fetch($facid); currency);?> - diff --git a/htdocs/cashdesk/tpl/validation1.tpl.php b/htdocs/cashdesk/tpl/validation1.tpl.php index e8c16712b74..fcbd95e8f29 100644 --- a/htdocs/cashdesk/tpl/validation1.tpl.php +++ b/htdocs/cashdesk/tpl/validation1.tpl.php @@ -36,16 +36,16 @@ $langs->loadLangs(array("main","bills","banks")); trans("Invoice"); ?>numInvoice(); ?> trans("TotalHT"); ?>prixTotalHt(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?> - montantTva() ) { - echo (''.$langs->trans("VAT").''.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); - } - else - { - echo (''.$langs->trans("VAT").''.$langs->trans("NoVAT").''); - } - ?> +montantTva() ) { + echo (''.$langs->trans("VAT").''.price(price2num($obj_facturation->montantTva(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); +} +else +{ + echo (''.$langs->trans("VAT").''.$langs->trans("NoVAT").''); +} +?> trans("TotalTTC"); ?> prixTotalTtc(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?> trans("PaymentMode"); ?> loadLangs(array("main","bills","banks")); ?> - getsetPaymentMode() == 'DIF' ) { - echo (''.$langs->trans("DateDue").''.$obj_facturation->paiementLe().''); - } else { - echo (''.$langs->trans("Received").''.price(price2num($obj_facturation->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); - } +getsetPaymentMode() == 'DIF' ) { + echo (''.$langs->trans("DateDue").''.$obj_facturation->paiementLe().''); +} else { + echo (''.$langs->trans("Received").''.price(price2num($obj_facturation->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); +} - // Affichage du montant rendu (reglement en especes) - if ( $obj_facturation->montantRendu() ) { - echo (''.$langs->trans("Change").''.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); - } +// Affichage du montant rendu (reglement en especes) +if ( $obj_facturation->montantRendu() ) { + echo (''.$langs->trans("Change").''.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).''); +} - ?> +?> diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6e8c5535f03..15a6f820647 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -94,7 +94,7 @@ if ($id > 0 && $action!='add') { $ret1 = $object->fetch_userassigned(); } if ($ret < 0 || $ret1 < 0) { - dol_print_error('', $object->error); + dol_print_error('', $object->error); } } @@ -1582,19 +1582,20 @@ if ($id > 0) if ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 871ec6b9ed2..8432ba786a1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -484,9 +484,9 @@ class ActionComm extends CommonObject return $this->id; } else - { - $this->db->rollback(); - return -1; + { + $this->db->rollback(); + return -1; } } else @@ -1043,7 +1043,7 @@ class ActionComm extends CommonObject return $resarray; } else - { + { return $db->lasterror(); } } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 7c696b70247..5587da16556 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -379,7 +379,7 @@ class ICal return $temp; } else - { + { return false; } } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index d503c1bc71d..9ad3ef80dde 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -519,14 +519,14 @@ if (! empty($actioncode)) elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; else { - if (is_array($actioncode)) - { + if (is_array($actioncode)) + { $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } + else + { $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } + } } } } @@ -1729,11 +1729,24 @@ function dol_color_minus($color, $minus, $minusunit = 16) */ function sort_events_by_date($a, $b) { - if($a->datep != $b->datep) - { - return $a->datep - $b->datep; - } + if($a->datep != $b->datep) + { + return $a->datep - $b->datep; + } - // If both events have the same start time, longest first - return $b->datef - $a->datef; + // If both events have the same start time, longest first + + if(! is_numeric($b->datef)) + { + // when event B have no end timestamp, event B should sort be before event A (All day events on top) + return 1; + } + + if(! is_numeric($a->datef)) + { + // when event A have no end timestamp , event A should sort be before event B (All day events on top) + return -1; + } + + return $b->datef - $a->datef; } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index c873adee9de..02277fc30e8 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -41,8 +41,8 @@ $id = GETPOST('id', 'int'); // Security check if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id'); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 194c9a2ae33..1b33e5da9b8 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -702,15 +702,15 @@ if ($resql) // Linked object if (! empty($arrayfields['a.fk_element']['checked'])) { - print ''; - //var_dump($obj->fkelement.' '.$obj->elementtype); - if ($obj->fk_element > 0 && ! empty($obj->elementtype)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); - } else { - print " "; - } - print ''; + print ''; + //var_dump($obj->fkelement.' '.$obj->elementtype); + if ($obj->fk_element > 0 && ! empty($obj->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1); + } else { + print " "; + } + print ''; } // Extra fields diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index fc343f443a2..ce577de78bd 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -418,14 +418,14 @@ if (! empty($actioncode)) elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'"; else { - if (is_array($actioncode)) - { + if (is_array($actioncode)) + { $sql.=" AND ca.code IN ('".implode("','", $actioncode)."')"; - } - else - { + } + else + { $sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')"; - } + } } } } @@ -683,16 +683,16 @@ while($currentdaytoshow<$lastdaytoshow) { { foreach ($eventarray as $daykey => $notused) { - // Get all assigned users for each event - foreach ($eventarray[$daykey] as $index => $event) - { - $event->fetch_userassigned(); + // Get all assigned users for each event + foreach ($eventarray[$daykey] as $index => $event) + { + $event->fetch_userassigned(); $listofuserid=$event->userassigned; foreach($listofuserid as $userid => $tmp) { if (! in_array($userid, $usernamesid)) $usernamesid[$userid] = $userid; } - } + } } } /* Use this list to have for all users */ diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 576851b7e2e..57239c355b4 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -565,7 +565,7 @@ if ($object->id > 0) if ($object->stcomm_id != $val['id']) print ''.img_action($titlealt, $val['code']).''; } print ''; - print ""; + print ""; } print '
'; @@ -1297,8 +1297,8 @@ if ($object->id > 0) { if ($object->client != 0 && $object->client != 2) { - if (! empty($orders2invoice) && $orders2invoice > 0) print ''; - else print ''; + if (! empty($orders2invoice) && $orders2invoice > 0) print ''; + else print ''; } else print ''; } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 0e0354a5641..10314b597e7 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -59,13 +59,13 @@ llxHeader('', $langs->trans("Contacts")); if ($type == "c" || $type == "p") { - $label = $langs->trans("Customers"); - $urlfiche="card.php"; + $label = $langs->trans("Customers"); + $urlfiche="card.php"; } if ($type == "f") { - $label = $langs->trans("Suppliers"); - $urlfiche="card.php"; + $label = $langs->trans("Suppliers"); + $urlfiche="card.php"; } /* @@ -88,29 +88,29 @@ if ($socid) $sql.= " AND s.rowid = ".$socid; if (dol_strlen($stcomm)) { - $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); + $sql.= " AND s.fk_stcomm=".$db->escape($stcomm); } if (! empty($search_lastname)) { - $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; + $sql.= " AND p.name LIKE '%".$db->escape($search_lastname)."%'"; } if (! empty($search_firstname)) { - $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; + $sql.= " AND p.firstname LIKE '%".$db->escape($search_firstname)."%'"; } if (! empty($search_company)) { - $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; + $sql.= " AND s.nom LIKE '%".$db->escape($search_company)."%'"; } if (! empty($contactname)) // acces a partir du module de recherche { - $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; - $sortfield = "p.name"; - $sortorder = "ASC"; + $sql.= " AND (p.name LIKE '%".$db->escape($contactname)."%' OR lower(p.firstname) LIKE '%".$db->escape($contactname)."%') "; + $sortfield = "p.name"; + $sortorder = "ASC"; } $sql.= $db->order($sortfield, $sortorder); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 33de68f22a1..c16d7237439 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -851,7 +851,7 @@ else setEventMessages('', null, 'warnings'); if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. { - setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"]=''; } diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 0f3e42d366f..e5d096dea26 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -131,7 +131,7 @@ if (is_resource($handle)) } else { - dol_print_error($db); + dol_print_error($db); } print ''; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0f84fdd5552..113d3baf503 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -9,10 +9,10 @@ * Copyright (C) 2010-2018 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Cedric Salvador - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2014 Ferran Marcet - * Copyright (C) 2016 Marcos García - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2016 Marcos García + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -166,7 +166,7 @@ if (empty($reshook)) if ($object->id > 0) { if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) { //Get difference between old and new delivery date and change lines according to difference - $date_delivery = dol_mktime(12, 0, 0, + $date_delivery = dol_mktime(12, 0, 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int') @@ -174,7 +174,7 @@ if (empty($reshook)) if (!empty($object->date_livraison) && !empty($date_delivery)) { //Attempt to get the date without possible hour rounding errors - $old_date_delivery = dol_mktime(12, 0, 0, + $old_date_delivery = dol_mktime(12, 0, 0, dol_print_date($object->date_livraison, '%m'), dol_print_date($object->date_livraison, '%d'), dol_print_date($object->date_livraison, '%Y') @@ -459,91 +459,91 @@ if (empty($reshook)) $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); + $classname = ucfirst($subelement); + $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); - if ($result > 0) + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + $srcobject->fetch_lines(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; - } - - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - - // Date start - $date_start = false; - if ($lines[$i]->date_debut_prevue) - $date_start = $lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) - $date_start = $lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) - $date_start = $lines[$i]->date_start; - - // Date end - $date_end = false; - if ($lines[$i]->date_fin_prevue) - $date_end = $lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) - $date_end = $lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) - $date_end = $lines[$i]->date_end; - - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $tva_tx = $lines[$i]->tva_tx; - if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - - $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } - } - - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) - $error ++; - } else { - setEventMessages($srcobject->error, $srcobject->errors, 'errors'); - $error ++; } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + + // Date start + $date_start = false; + if ($lines[$i]->date_debut_prevue) + $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) + $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) + $date_start = $lines[$i]->date_start; + + // Date end + $date_end = false; + if ($lines[$i]->date_fin_prevue) + $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) + $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) + $date_end = $lines[$i]->date_end; + + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; + } + + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals(); + $array_options = $lines[$i]->array_options; + } + + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; + $error ++; + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) + $error ++; + } else { + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $error ++; + } } else { setEventMessages($object->error, $object->errors, 'errors'); $error ++; @@ -920,8 +920,8 @@ if (empty($reshook)) $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } // If price per customer @@ -1325,17 +1325,17 @@ if (empty($reshook)) $object->setProject(GETPOST('projectid', 'int')); } - // Delai de livraison + // Delivery time elseif ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id', 'int')); } - // Origine de la propale + // Origin of the commercial proposal elseif ($action == 'setdemandreason' && $usercancreate) { $result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int')); } - // Conditions de reglement + // Terms of payment elseif ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } @@ -1348,7 +1348,7 @@ if (empty($reshook)) $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } - // Mode de reglement + // Payment choice elseif ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } @@ -1413,7 +1413,7 @@ if (empty($reshook)) } } - // Bascule du statut d'un contact + // Toggle the status of a contact elseif ($action == 'swapstatut') { if ($object->fetch($id) > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); @@ -1422,7 +1422,7 @@ if (empty($reshook)) } } - // Efface un contact + // Delete a contact elseif ($action == 'deletecontact') { $object->fetch($id); $result = $object->delete_contact($lineid); @@ -1600,7 +1600,7 @@ if ($action == 'create') $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print ''; - // Ligne info remises tiers + // Third party discounts info line print '' . $langs->trans('Discounts') . ''; $absolute_discount = $soc->getAvailableDiscounts(); @@ -1787,7 +1787,7 @@ if ($action == 'create') /* - * Combobox pour la fonction de copie + * Combobox for copy function */ if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print ''; @@ -1884,7 +1884,7 @@ if ($action == 'create') if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) { $formquestion[] = array('type' => 'date','name' => 'date_delivery','label' => $langs->trans("DeliveryDate"),'value' => $object->date_livraison); } - // Paiement incomplet. On demande si motif = escompte ou autre + // Incomplete payment. We ask if reason = discount or other $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmClonePropal', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } @@ -1927,7 +1927,7 @@ if ($action == 'create') elseif ($action == 'validate') { $error = 0; - // We verifie whether the object is provisionally numbering + // We verify whether the object is provisionally numbering $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 7afb14a8da2..1337c62da94 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -227,7 +227,7 @@ class Proposals extends DolibarrApi } if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->propal->getLinesArray(); $result = array(); @@ -255,7 +255,7 @@ class Proposals extends DolibarrApi $result = $this->propal->fetch($id); if (! $result) { - throw new RestException(404, 'Commercial Proposal not found'); + throw new RestException(404, 'Commercial Proposal not found'); } if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a55b4a28172..a2b89dedb11 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1714,9 +1714,9 @@ class Propal extends CommonObject // multilangs if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); } $this->lines[$i] = $line; @@ -3403,7 +3403,7 @@ class Propal extends CommonObject { $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; - $line->product_ref='SPECIMEN'; + $line->product_ref='SPECIMEN'; } $this->lines[$xnbp]=$line; @@ -3919,7 +3919,7 @@ class PropaleLigne extends CommonObjectLine if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0; if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0; - // if buy price not defined, define buyprice as configured in margin admin + // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 96673084580..cb798e2fdd6 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -170,20 +170,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index eca5ce52fa7..c1719ddbe45 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -125,20 +125,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index 108a09e7d07..848d707f22f 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -86,20 +86,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 919ad77168d..01d4c264667 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -139,6 +139,7 @@ $fieldstosearchall = array( 'p.ref_client'=>'CustomerRef', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", 'p.note_public'=>'NotePublic', ); if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate"; @@ -279,8 +280,9 @@ $sql.= ' u.login'; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -693,7 +695,7 @@ if ($resql) print ''; print ''; } - // Date cloture + // Date cloture if (! empty($arrayfields['p.date_cloture']['checked'])) { print ''; diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 2a3f0438ad0..7c3d58f64d5 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -101,20 +101,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->propal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 4de75dc3225..ccc62ab98c4 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -29,11 +29,8 @@ if (empty($conf) || ! is_object($conf)) { exit; } -?> - - -\n"; global $user; @@ -45,51 +42,46 @@ $langs->load("propal"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> - - trans("Proposal"); ?> - global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) + print ''; + print ''.$langs->trans("Proposal"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; print ' '; } - ?> - - getNomUrl(1); ?> - ref_client; ?> - date, 'day'); ?> - rights->propale->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> - getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - -'; + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date, 'day').''; + print ''; + if ($user->rights->propale->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + print ''; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - ?> - - trans("Total"); ?> - - - - - - - -'; + print ''.$langs->trans("Total").''; + print ''; + print ''; + print ''; + print ''.price($total).''; + print ''; + print ''; + print "\n"; } -?> - +print "\n"; diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index c1339f7ebe9..192aaccbddf 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -34,8 +34,8 @@ if (! empty($conf->facture->enabled)) $langs->load("bills"); $socid = $_GET["socid"]; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index 7f16ce6b8b0..0759c47c06c 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -34,8 +34,8 @@ if (! empty($conf->facture->enabled)) $langs->load("bills"); $socid = $_GET["socid"]; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 115bc46813a..37dd5a8d570 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -120,6 +120,7 @@ $fieldstosearchall = array( 'c.ref_client'=>'RefCustomerOrder', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", 'c.note_public'=>'NotePublic', ); if (empty($user->socid)) $fieldstosearchall["c.note_private"]="NotePrivate"; diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index b82cee983f9..7f96d9e28e7 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -306,7 +306,7 @@ else $log="graph.php: min=".$min." max=".$max; dol_syslog($log); -// CRED PART + // CRED PART // Chargement du tableau des années $tblyear[0] = array(); $tblyear[1] = array(); @@ -393,7 +393,7 @@ else unset($tblyear[1]); unset($tblyear[2]); -// DEDBT PART + // DEDBT PART // Chargement du tableau des années $tblyear[0] = array(); $tblyear[1] = array(); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 71eb5faa6c9..457e311d01c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1315,33 +1315,33 @@ if ($resql) // Date ope if (! empty($arrayfields['b.dateo']['checked'])) { - print ''; - print ''.dol_print_date($db->jdate($objp->do), "day").""; - print ' '; - print ''; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print "\n"; + print ''; + print ''.dol_print_date($db->jdate($objp->do), "day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; if (! $i) $totalarray['nbfield']++; } // Date value if (! empty($arrayfields['b.datev']['checked'])) { - print ''; - print ''.dol_print_date($db->jdate($objp->dv), "day").""; - print ' '; - print ''; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print "\n"; - if (! $i) $totalarray['nbfield']++; + print ''; + print ''.dol_print_date($db->jdate($objp->dv), "day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; } // Payment type @@ -1352,7 +1352,7 @@ if ($resql) if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); else print $labeltype; print "\n"; - if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['nbfield']++; } // Num cheque diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index cfecc31427b..53fa268b750 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1360,10 +1360,10 @@ class Account extends CommonObject $linkstart = 'global->BANK_SHOW_ORDER_OPTION) + preg_replace('/ ?[^Bank]AccountNumber ?/', 'BankAccountNumber', + $conf->global->BANK_SHOW_ORDER_OPTION) ); } } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index eeea2b72ce5..cec68cf2c3a 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -322,7 +322,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) print ''; print ""; - print "
"; + print "
"; } else { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 9260ee3f1f9..5cb9d3c9558 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -427,19 +427,20 @@ if ($id) $morehtmlref.=$langs->trans('Project') . ' '; if ($user->rights->banque->modifier) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index a196540d484..21598990aba 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -92,19 +92,20 @@ if ($object->id) $morehtmlref.=$langs->trans('Project') . ' : '; if ($user->rights->banque->modifier && 0) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index 4cc64bb830e..7d55703802e 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -61,19 +61,20 @@ if (! empty($conf->projet->enabled)) $morehtmlref.=$langs->trans('Project') . ' : '; if ($user->rights->banque->modifier && 0) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index adb5a74425c..6a320970396 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -415,9 +415,9 @@ elseif ($id) } else { - /* - * Confirm delete trip - */ + /* + * Confirm delete trip + */ if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index de32cb9c3eb..1b70641a6bc 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -89,11 +89,11 @@ class Deplacement extends CommonObject public $statuts=array(); public $statuts_short=array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ + /** + * Constructor + * + * @param DoliDB $db Database handler + */ public function __construct($db) { $this->db = $db; @@ -249,13 +249,13 @@ class Deplacement extends CommonObject } } - /** - * Load an object from database - * - * @param int $id Id of record to load - * @param string $ref Ref of record - * @return int <0 if KO, >0 if OK - */ + /** + * Load an object from database + * + * @param int $id Id of record to load + * @param string $ref Ref of record + * @return int <0 if KO, >0 if OK + */ public function fetch($id, $ref = '') { $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet as fk_project, extraparams"; @@ -293,12 +293,12 @@ class Deplacement extends CommonObject } } - /** - * Delete record - * - * @param int $id Id of record to delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete record + * + * @param int $id Id of record to delete + * @return int <0 if KO, >0 if OK + */ public function delete($id) { $this->db->begin(); @@ -413,9 +413,9 @@ class Deplacement extends CommonObject */ public function listOfTypes($active = 1) { - global $langs; + global $langs; - $ret=array(); + $ret=array(); $sql = "SELECT id, code, label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_fees"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fe88c9ec717..08fbb019fd2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -14,7 +14,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014-2019 Ferran Marcet * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -809,14 +809,16 @@ if (empty($reshook)) // Total credit note and deposit $total_creditnote_and_deposit = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; - $sql .= " WHERE fk_facture = " . $object->id; - $resql = $db->query($sql); - if (!empty($resql)) { - while ($obj = $db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; - } else dol_print_error($db); + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; + $sql .= " WHERE fk_facture = " . $object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) { + $total_creditnote_and_deposit += $obj->amount_ttc; + } + } else dol_print_error($db); $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; @@ -1516,7 +1518,7 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $localtax1_tx, $localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $object->origin, $lines[$i]->rowid, @@ -2726,7 +2728,7 @@ if ($action == 'create') $text.=' '.$langs->trans("ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv("MenuFinancial"), $langs->transnoentitiesnoconv("BillsCustomers"), $langs->transnoentitiesnoconv("ListOfTemplates")); if (empty($conf->global->INVOICE_DISABLE_AUTOMATIC_RECURRING_INVOICE)) { - $text.=' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); + $text.=' '.$langs->trans("ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv('Module2300Name')); } print info_admin($text, 0, 0, 0).'
'; } @@ -3274,12 +3276,12 @@ if ($action == 'create') print ''; include_once DOL_DOCUMENT_ROOT . '/core/modules/facture/modules_facture.php'; $liste = ModelePDFFactures::liste_modeles($db); - if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)){ // Hidden conf - $paramkey='FACTURE_ADDON_PDF_'.$object->type; - $curent = !empty($conf->global->$paramkey)?$conf->global->$paramkey:$conf->global->FACTURE_ADDON_PDF; - } - else{ - $curent = $conf->global->FACTURE_ADDON_PDF; + if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)){ + // Hidden conf + $paramkey='FACTURE_ADDON_PDF_'.$object->type; + $curent = !empty($conf->global->$paramkey)?$conf->global->$paramkey:$conf->global->FACTURE_ADDON_PDF; + } else { + $curent = $conf->global->FACTURE_ADDON_PDF; } print $form->selectarray('model', $liste, $curent); print ""; @@ -3803,19 +3805,20 @@ elseif ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($usercancreate) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 654af5aeaac..25d92fad92a 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -415,7 +415,7 @@ class Invoices extends DolibarrApi return $this->_cleanObjectDatas($this->invoice); } - /** + /** * Delete a contact type of given invoice * * @param int $id Id of invoice to update @@ -529,10 +529,9 @@ class Invoices extends DolibarrApi // update bank account if (!empty($this->invoice->fk_account)) { - if($this->invoice->setBankAccount($this->invoice->fk_account) == 0) - { - throw new RestException(400, $this->invoice->error); - } + if ($this->invoice->setBankAccount($this->invoice->fk_account) == 0) { + throw new RestException(400, $this->invoice->error); + } } if($this->invoice->update(DolibarrApiAccess::$user)) @@ -909,18 +908,18 @@ class Invoices extends DolibarrApi $result = $this->invoice->fetch($id); - if( ! $result ) { + if (! $result) { throw new RestException(404, 'Invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { + if (! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } return $this->_cleanObjectDatas($this->invoice); } - /** + /** * Create a discount (credit available) for a credit note or a deposit. * * @param int $id Invoice ID diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0cb6921a6f3..8859578e94b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -862,10 +862,10 @@ class Facture extends CommonInvoice if (! $error && ! $notrigger) { - // Call trigger - $result=$this->call_trigger('BILL_CREATE', $user); - if ($result < 0) $error++; - // End call triggers + // Call trigger + $result=$this->call_trigger('BILL_CREATE', $user); + if ($result < 0) $error++; + // End call triggers } if (! $error) @@ -1605,9 +1605,9 @@ class Facture extends CommonInvoice // multilangs if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); } $this->lines[$i] = $line; @@ -2545,7 +2545,7 @@ class Facture extends CommonInvoice if (empty($final)) $this->situation_final = 0; else $this->situation_final = 1; - $this->setFinal($user); + $this->setFinal($user); } } } @@ -2587,10 +2587,12 @@ class Facture extends CommonInvoice $next_invoice->brouillon = 1; foreach ($next_invoice->lines as $line) { - $result = $next_invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, - $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, - $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, - $line->fk_unit); + $result = $next_invoice->updateline( + $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, + $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, + $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, + $line->fk_unit + ); if ($result < 0) { diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 5fb26a21cd6..62960b71346 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -163,20 +163,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->facture->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index fb56ccb916f..79780402108 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1242,19 +1242,20 @@ else $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->facture->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index e13dc30204f..f714d51cf6e 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -223,8 +223,9 @@ $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended, $sql.= " f.datec, f.tms,"; $sql.= " f.fk_cond_reglement, f.fk_mode_reglement"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -513,68 +514,68 @@ if ($resql) if (! empty($arrayfields['f.titre']['checked'])) { - print ''; - print $invoicerectmp->getNomUrl(1); - print ""; - print "\n"; - if (! $i) $totalarray['nbfield']++; + print ''; + print $invoicerectmp->getNomUrl(1); + print ""; + print "\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['s.nom']['checked'])) { - print ''.$companystatic->getNomUrl(1, 'customer').''; - if (! $i) $totalarray['nbfield']++; + print ''.$companystatic->getNomUrl(1, 'customer').''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.total']['checked'])) { - print ''.price($objp->total).''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; - $totalarray['val']['f.total'] += $objp->total; + print ''.price($objp->total).''."\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; + $totalarray['val']['f.total'] += $objp->total; } if (! empty($arrayfields['f.tva']['checked'])) { - print ''.price($objp->total_vat).''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; - $totalarray['val']['f.tva'] += $objp->total_vat; + print ''.price($objp->total_vat).''."\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; + $totalarray['val']['f.tva'] += $objp->total_vat; } if (! empty($arrayfields['f.total_ttc']['checked'])) { - print ''.price($objp->total_ttc).''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; - $totalarray['val']['f.total_ttc'] += $objp->total_ttc; + print ''.price($objp->total_ttc).''."\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; + $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } // Payment term if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) { - print ''; - print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); - print ''."\n"; - if (! $i) $totalarray['nbfield']++; + print ''; + print $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); + print ''."\n"; + if (! $i) $totalarray['nbfield']++; } // Payment mode if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) { - print ''; - print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); - print ''."\n"; - if (! $i) $totalarray['nbfield']++; + print ''; + print $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); + print ''."\n"; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['recurring']['checked'])) { - print ''.yn($objp->frequency?1:0).''; - if (! $i) $totalarray['nbfield']++; + print ''.yn($objp->frequency?1:0).''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.frequency']['checked'])) { - print ''.($objp->frequency > 0 ? $objp->frequency : '').''; - if (! $i) $totalarray['nbfield']++; + print ''.($objp->frequency > 0 ? $objp->frequency : '').''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.unit_frequency']['checked'])) { - print ''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; - if (! $i) $totalarray['nbfield']++; + print ''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.nb_gen_done']['checked'])) { @@ -586,10 +587,10 @@ if ($resql) // Date last generation if (! empty($arrayfields['f.date_last_gen']['checked'])) { - print ''; - print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); + print ''; + if (! $i) $totalarray['nbfield']++; } // Date next generation if (! empty($arrayfields['f.date_when']['checked'])) @@ -611,17 +612,17 @@ if ($resql) } if (! empty($arrayfields['f.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($objp->datec), 'dayhour'); - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + print dol_print_date($db->jdate($objp->datec), 'dayhour'); + print ''; + if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['f.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($objp->tms), 'dayhour'); - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + print dol_print_date($db->jdate($objp->tms), 'dayhour'); + print ''; + if (! $i) $totalarray['nbfield']++; } $obj = $objp; @@ -632,12 +633,11 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status - if (! empty($arrayfields['status']['checked'])) - { - print ''; - print $invoicerectmp->getLibStatut(3, 0); - print ''; - if (! $i) $totalarray['nbfield']++; + if (! empty($arrayfields['status']['checked'])) { + print ''; + print $invoicerectmp->getLibStatut(3, 0); + print ''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 4642c0b7da1..5f1ce9e44c3 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -400,8 +400,9 @@ $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) +if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -1346,32 +1347,31 @@ if ($resql) // Show total line if (isset($totalarray['totalhtfield']) - || isset($totalarray['totalvatfield']) - || isset($totalarray['totallocaltax1field']) - || isset($totalarray['totallocaltax2field']) - || isset($totalarray['totalttcfield']) - || isset($totalarray['totalamfield']) - || isset($totalarray['totalrtpfield']) - ) - { + || isset($totalarray['totalvatfield']) + || isset($totalarray['totallocaltax1field']) + || isset($totalarray['totallocaltax2field']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print ''; $i=0; while ($i < $totalarray['nbfield']) { - $i++; - if ($i == 1) - { + $i++; + if ($i == 1) + { if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; - elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; - elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).''; - elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).''; - elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; - elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).''; - elseif ($totalarray['totalrtpfield'] == $i) print ''.price($totalarray['totalrtp']).''; - else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; + elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; + elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).''; + elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).''; + elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; + elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).''; + elseif ($totalarray['totalrtpfield'] == $i) print ''.price($totalarray['totalrtp']).''; + else print ''; } print ''; } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 45bbfc3eef3..cf59af89cf6 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -189,20 +189,21 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->facture->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index d475c5c3e5f..dadbb27b30d 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -233,48 +233,45 @@ foreach ($tmp_companies as $value) { print '
'; -//if (empty($socid)) -//{ - // Show filter box - print '
'; - print ''; - print ''; - print ''; - // Company - print ''; - // User - print ''; - // Status - print ''; - // Year - print ''; - print ''; - print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; - if ($mode == 'customer') $filter='s.client in (1,2,3)'; - if ($mode == 'supplier') $filter='s.fournisseur = 1'; - print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); - print '
'.$langs->trans("CreatedBy").''; - print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print '
'.$langs->trans("Status").''; - if ($mode == 'customer') - { - $liststatus=array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); - print $form->selectarray('object_status', $liststatus, $object_status, 1); - } - if ($mode == 'supplier') - { - $liststatus=array('0'=>$langs->trans("BillStatusDraft"),'1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); - print $form->selectarray('object_status', $liststatus, $object_status, 1); - } - print '
'.$langs->trans("Year").''; - if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; - if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; - arsort($arrayyears); - print $form->selectarray('year', $arrayyears, $year, 0); - print '
'; - print '
'; - print '

'; -//} +// Show filter box +print '
'; +print ''; +print ''; +print ''; +// Company +print ''; +// User +print ''; +// Status +print ''; +// Year +print ''; +print ''; +print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; +if ($mode == 'customer') $filter='s.client in (1,2,3)'; +if ($mode == 'supplier') $filter='s.fournisseur = 1'; +print $form->selectarray('socid', $companies, $socid, 1, 0, 0, 'style="width: 95%"', 0, 0, 0, '', '', 1); +print '
'.$langs->trans("CreatedBy").''; +print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); +print '
'.$langs->trans("Status").''; +if ($mode == 'customer') +{ + $liststatus=array('0'=>$langs->trans("BillStatusDraft"), '1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid"), '3'=>$langs->trans("BillStatusCanceled")); + print $form->selectarray('object_status', $liststatus, $object_status, 1); +} +if ($mode == 'supplier') +{ + $liststatus=array('0'=>$langs->trans("BillStatusDraft"),'1'=>$langs->trans("BillStatusNotPaid"), '2'=>$langs->trans("BillStatusPaid")); + print $form->selectarray('object_status', $liststatus, $object_status, 1); +} +print '
'.$langs->trans("Year").''; +if (! in_array($year, $arrayyears)) $arrayyears[$year]=$year; +if (! in_array($nowyear, $arrayyears)) $arrayyears[$nowyear]=$nowyear; +arsort($arrayyears); +print $form->selectarray('year', $arrayyears, $year, 0); +print '
'; +print '
'; +print '

'; print '
'; print ''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index b48c0478609..d2cad75ca77 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -24,11 +24,7 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - - - -\n"; global $user; global $noMoreLinkedObjectBlockAfter; @@ -40,73 +36,70 @@ $langs->load("bills"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> - - - - - - - - - -element.'" data-id="'.$objectlink->id.'" >'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; } if (count($linkedObjectBlock) > 1) { - ?> - - - - - - - - - - '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } -?> - +print "\n"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index f6f854d9635..cb16ce407f8 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -24,11 +24,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; -load("bills"); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> + if ($user->rights->facture->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } + ?> - 1) { @@ -75,6 +75,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index c56b663a77b..1453491fd11 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -115,6 +115,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
'; print '
type) { - case Facture::TYPE_REPLACEMENT: - echo $langs->trans("InvoiceReplacement"); - break; - case Facture::TYPE_CREDIT_NOTE: - echo $langs->trans("InvoiceAvoir"); - break; - case Facture::TYPE_DEPOSIT: - echo $langs->trans("InvoiceDeposit"); - break; - case Facture::TYPE_PROFORMA: - echo $langs->trans("InvoiceProForma"); - break; - case Facture::TYPE_SITUATION: - echo $langs->trans("InvoiceSituation"); - break; - default: - echo $langs->trans("CustomerInvoice"); - break; - } - ?>getNomUrl(1); ?>ref_client; ?>date, 'day'); ?>rights->facture->lire) { - $sign = 1; - if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; - if ($objectlink->statut != 3) // If not abandonned - { - $total = $total + $sign * $objectlink->total_ht; - echo price($objectlink->total_ht); - } - else - { - echo ''.price($objectlink->total_ht).''; - } - } ?>getLibStatut(3); ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; + switch ($objectlink->type) { + case Facture::TYPE_REPLACEMENT: + echo $langs->trans("InvoiceReplacement"); + break; + case Facture::TYPE_CREDIT_NOTE: + echo $langs->trans("InvoiceAvoir"); + break; + case Facture::TYPE_DEPOSIT: + echo $langs->trans("InvoiceDeposit"); + break; + case Facture::TYPE_PROFORMA: + echo $langs->trans("InvoiceProForma"); + break; + case Facture::TYPE_SITUATION: + echo $langs->trans("InvoiceSituation"); + break; + default: + echo $langs->trans("CustomerInvoice"); + break; + } + print ''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; + if ($user->rights->facture->lire) { + $sign = 1; + if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = -1; + if ($objectlink->statut != 3) { + // If not abandonned + $total = $total + $sign * $objectlink->total_ht; + echo price($objectlink->total_ht); + } + else + { + echo ''.price($objectlink->total_ht).''; + } + } + print ''.$objectlink->getLibStatut(3).''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'
trans("Total"); ?>
'.$langs->trans("Total").''.price($total).'
trans("RepeatableInvoice"); ?> getNomUrl(1); ?> date_when, 'day'); ?> rights->facture->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'; $i=0; foreach($listofsearchfields as $key => $value) @@ -127,6 +128,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
'; + print '
'; print ''; print '
'; } @@ -165,6 +167,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { $num = $db->num_rows($resql); + print '
'; print ''; print ''; print ''; @@ -216,7 +219,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { print ''; } - print "
'.$langs->trans("CustomersDraftInvoices").($num?' '.$num.'':'').'
'.$langs->trans("NoInvoice").'

"; + print "

"; $db->free($resql); } else @@ -251,6 +254,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { $num = $db->num_rows($resql); + print '
'; print ''; print ''; print ''; @@ -303,7 +307,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- { print ''; } - print "
'.$langs->trans("SuppliersDraftInvoices").($num?' '.$num.'':'').'
'.$langs->trans("NoInvoice").'

"; + print "

"; $db->free($resql); } else diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 5e89f68e8ba..0251173a863 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -320,323 +320,318 @@ else $span=$columns; if ($modetax != 1) $span+=2; - //if ($modetax == 0 || $modetax == 2) - //{ - // Customers invoices - print ''; - print ''.$elementcust.''; - print ''.$productcust.''; - if ($modetax != 2) print ''.$amountcust.''; - if ($modetax != 1) print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; - print ''.$langs->trans("BI").''; - print ''.$vatcust.''; - print ''; + // Customers invoices + print ''; + print ''.$elementcust.''; + print ''.$productcust.''; + if ($modetax != 2) print ''.$amountcust.''; + if ($modetax != 1) print ''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'; + print ''.$langs->trans("BI").''; + print ''.$vatcust.''; + print ''; - $LT=0; - $sameLT=false; - foreach(array_keys($x_coll) as $rate) + $LT=0; + $sameLT=false; + foreach(array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; + + if (is_array($x_both[$rate]['coll']['detail'])) { - $subtot_coll_total_ht = 0; - $subtot_coll_vat = 0; - - if (is_array($x_both[$rate]['coll']['detail'])) + // VAT Rate + if($rate!=0){ + print ""; + print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; + print ''."\n"; + } + foreach($x_both[$rate]['coll']['detail'] as $index => $fields) { - // VAT Rate - if($rate!=0){ - print ""; - print ''.$langs->trans("Rate").': '.vatrate($rate).'%'; - print ''."\n"; - } - foreach($x_both[$rate]['coll']['detail'] as $index => $fields) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; + + + print ''; + + // Ref + print ''.$fields['link'].''; + + // Description + print ''; + if ($fields['pid']) { - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; - - - print ''; - - // Ref - print ''.$fields['link'].''; - - // Description - print ''; - if ($fields['pid']) - { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - } - else - { - if ($type) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); - if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) - { - if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); - elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); - else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); - } - print ''; - - // Total HT - if ($modetax != 2) - { - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - } - print ''; - } - - // Payment - $ratiopaymentinvoice=1; - if ($modetax != 1) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $payment_static->id=$fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NotUsedForGoods"); - } - else { - print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; - } - print ''; - } - - // Total collected - print ''; - $temp_ht=$fields['totalht']; - if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT')); - print ''; - - // Localtax - print ''; - $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; - print price(price2num($temp_vat, 'MT')); - //print price($fields['vat']); - print ''; - print ''; - - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); } + else + { + if ($type) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); + if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) + { + if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print ''; + + // Total HT + if ($modetax != 2) + { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + } + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $payment_static->id=$fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NotUsedForGoods"); + } + else { + print price($fields['payment_amount']); + if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; + } + print ''; + } + + // Total collected + print ''; + $temp_ht=$fields['totalht']; + if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT')); + print ''; + + // Localtax + print ''; + $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; + print price(price2num($temp_vat, 'MT')); + //print price($fields['vat']); + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } } - - // Total customers for this vat rate - print ''; - print ''; - print ''.$langs->trans("Total").':'; - if ($modetax != 1) - { - print ' '; - print ' '; - } - print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; - print ''.price(price2num($subtot_coll_vat, 'MT')).''; - print ''; } - if (count($x_coll) == 0) // Show a total ine if nothing shown + // Total customers for this vat rate + print ''; + print ''; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { - print ''; - print ' '; - print ''.$langs->trans("Total").':'; - if ($modetax == 0) - { - print ' '; - print ' '; - } - print ''.price(price2num(0, 'MT')).''; - print ''.price(price2num(0, 'MT')).''; - print ''; + print ' '; + print ' '; } + print ''.price(price2num($subtot_coll_total_ht, 'MT')).''; + print ''.price(price2num($subtot_coll_vat, 'MT')).''; + print ''; + } - // Blank line - print ' '; - print ''; - $diff=$x_coll_sum; - //} + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ' '; + print ''.$langs->trans("Total").':'; + if ($modetax == 0) + { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } - //if($conf->global->$calc ==0 || $conf->global->$calc == 1){ - echo ''; - //print table headers for this quadri - expenses now - print ''; - print ''; - print ''; - if ($modetax != 1) + // Blank line + print ''; + print '
'.$elementsup.''.$productsup.'
 
'; + $diff=$x_coll_sum; + + echo ''; + //print table headers for this quadri - expenses now + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''."\n"; + + foreach(array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; + + if (is_array($x_both[$rate]['paye']['detail'])) { - print ''; - print ''; - } - print ''; - print ''; - print ''."\n"; - - foreach(array_keys($x_paye) as $rate) - { - $subtot_paye_total_ht = 0; - $subtot_paye_vat = 0; - - if (is_array($x_both[$rate]['paye']['detail'])) + if($rate!=0){ + print ""; + print ''; + print ''."\n"; + } + foreach($x_both[$rate]['paye']['detail'] as $index=>$fields) { - if($rate!=0){ - print ""; - print ''; - print ''."\n"; - } - foreach($x_both[$rate]['paye']['detail'] as $index=>$fields) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; + + + print ''; + + // Ref + print ''; + + // Description + print ''; - print ''; - - // Ref - print ''; - - // Description - print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; - - // Total HT - if ($modetax != 2) - { - print ''; - } - - // Payment - $ratiopaymentinvoice=1; - if ($modetax != 1) - { - print ''; - } - - // VAT paid - print ''; - - // Localtax - print ''; - print ''; - - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; } + + // VAT paid + print ''; + + // Localtax + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } } - - // Total suppliers for this vat rate - print ''; - print ''; - print ''; - if ($modetax != 1) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; } - if (count($x_paye) == 0) { // Show a total line if nothing shown - print ''; - print ''; - print ''; - if ($modetax != 1) { - print ''; - print ''; - } - print ''; - print ''; - print ''; - } + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } - print '
'.$elementsup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatsup.'
'.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatsup.'
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$fields['link'].''; + if ($fields['pid']) { - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + } + else + { + if ($type) $text = img_object($langs->trans('Service'), 'service'); + else $text = img_object($langs->trans('Product'), 'product'); + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + // Show range + print_date_range($fields['ddate_start'], $fields['ddate_end']); + } + print '
'.$fields['link'].''; - if ($fields['pid']) + // Total HT + if ($modetax != 2) + { + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id=$fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NA"); } else { - if ($type) $text = img_object($langs->trans('Service'), 'service'); - else $text = img_object($langs->trans('Product'), 'product'); - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']), 16); - - // Show range - print_date_range($fields['ddate_start'], $fields['ddate_end']); + print price(price2num($fields['payment_amount'], 'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; + } } print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) - { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id=$fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NA"); - } - else - { - print price(price2num($fields['payment_amount'], 'MT')); - if (isset($fields['payment_amount'])) { - print ' ('.round($ratiopaymentinvoice*100, 2).'%)'; - } - } - print ''; - $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht, 'MT'), 1); - print ''; - $temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice; - print price(price2num($temp_vat, 'MT'), 1); - //print price($fields['vat']); - print '
'; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht, 'MT'), 1); + print ''; + $temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice; + print price(price2num($temp_vat, 'MT'), 1); + //print price($fields['vat']); + print '
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).'
 '.$langs->trans("Total").':  '.price(price2num(0, 'MT')).''.price(price2num(0, 'MT')).'
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht, 'MT')).''.price(price2num($subtot_paye_vat, 'MT')).'
'; - //} + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ' '; + print ''.$langs->trans("Total").':'; + if ($modetax != 1) { + print ' '; + print ' '; + } + print ''.price(price2num(0, 'MT')).''; + print ''.price(price2num(0, 'MT')).''; + print ''; + } + + print ''; // Total to pay print '

'; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 91000f2a822..def454f2ca5 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -168,20 +168,20 @@ if ($action == 'create') $charge->paiementtype=$charge->mode_reglement_id?$charge->mode_reglement_id:$charge->paiementtype; $total = $charge->amount; - if (! empty($conf->use_javascript_ajax)) - { - print "\n".''."\n"; - } + print ' '."\n"; + } print load_fiche_titre($langs->trans("DoPayment")); print "
\n"; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index ea5a4e8d07c..1282226623c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -271,7 +271,7 @@ if ($id > 0 || $ref) print ''.$langs->trans("TransMetod").''; print $form->selectarray("methode", $object->methodes_trans); print ''; -/* print ''.$langs->trans("File").''; + /*print ''.$langs->trans("File").''; print ''; print '
'; print '';*/ diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 5f2d73af0aa..4016ebdc813 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1686,7 +1686,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_ref,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.(($conf->global->PRELEVEMENT_END_TO_END != "" ) ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; @@ -1718,8 +1718,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; - // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max + // $XML_DEBITOR .=' '.($row_ref.'/'.$Rowing.'/'.$Rum).''.$CrLf; + // $XML_DEBITOR .=' '.dol_trunc($row_ref, 135).''.$CrLf; // 140 max $XML_DEBITOR .=' '.(($conf->global->PRELEVEMENT_USTRD != "" ) ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135) ).''.$CrLf; // 140 max $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1887,15 +1887,15 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$this->emetteur_bic.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; -/* $XML_SEPA_INFO .= ' '.$CrLf; + /* $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$this->raison_sociale.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ADDRESS.''.$CrLf; $XML_SEPA_INFO .= ' '.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.$CrLf; -*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; + $XML_SEPA_INFO .= ' '.$CrLf;*/ + $XML_SEPA_INFO .= ' SLEV'.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 24aa2f9bcb9..3dbfec69461 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -223,7 +223,7 @@ if ($resql) } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } if ($num > 0) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 5efa036055f..0503f31d6fb 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -749,17 +749,17 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $sql.= " AND fk_statut in (1,2)"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; - } - elseif ($modecompta == 'RECETTES-DEPENSES') { + } elseif ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; $sql.= " WHERE p.entity IN (".getEntity('donation').")"; $sql.= " AND fk_statut >= 2"; - if (! empty($date_start) && ! empty($date_end)) - $sql.= " AND pe.datep >= '".$db->idate($date_start)."' AND pe.datep <= '".$db->idate($date_end)."'"; - } + if (! empty($date_start) && ! empty($date_end)) { + $sql.= " AND pe.datep >= '".$db->idate($date_start)."' AND pe.datep <= '".$db->idate($date_end)."'"; + } + } $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index cc6280070a0..7399a7098c6 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -454,19 +454,20 @@ if ($id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->tax->charges->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 0cd02bc04bd..590269b332c 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -241,165 +241,163 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') } -if ($modecompta == 'CREANCES-DETTES') -{ -print ''; -print ''; -print ''; -print ''; -$i=0; -while($i < 12) -{ - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); - if ($j > 12) $j -= 12; - print ''; - $i++; -} -print ''; +if ($modecompta == 'CREANCES-DETTES') { + print '
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
'; + print ''; + print ''; + print ''; + $i=0; + while($i < 12) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + print ''; + $i++; + } + print ''; -$sql = "SELECT fd.tva_tx AS vatrate,"; -$sql .= " fd.product_type AS product_type,"; -$sql .= " cc.label AS country,"; -for ($i = 1; $i <= 12; $i ++) { - $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql .= " SUM(fd.total_ht) as total"; -$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; -$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; -$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; -$sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; -$sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; -$sql.= " AND f.fk_statut in (1,2)"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND f.type IN (0,1,2,5)"; -} else { - $sql.= " AND f.type IN (0,1,2,3,5)"; -} -$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; -$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; + $sql = "SELECT fd.tva_tx AS vatrate,"; + $sql .= " fd.product_type AS product_type,"; + $sql .= " cc.label AS country,"; + for ($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql .= " SUM(fd.total_ht) as total"; + $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; + $sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; + $sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; + $sql.= " AND f.fk_statut in (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND f.type IN (0,1,2,5)"; + } else { + $sql.= " AND f.type IN (0,1,2,3,5)"; + } + $sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; + $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; -dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql)) { - print ''; - if ($obj->product_type == 0) { - print ''; - } else { - print ''; + dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $totalpermonth = array(); + while ( $obj = $db->fetch_object($resql)) { + print ''; + if ($obj->product_type == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + } + print ''; + $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; } - print ''; + $db->free($resql); + + // Total + print ''; + print ''; + print ''; for($i = 0; $i < 12; $i++) { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; print ''; + } else { + print $db->lasterror(); // Show last sql error } - $db->free($resql); - // Total - print ''; - print ''; - print ''; - for($i = 0; $i < 12; $i++) { + + print ''; + print ''; + print ''; + $i=0; + while($i < 12) + { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; - $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; + $i++; } - print ''; - print ''; -} else { - print $db->lasterror(); // Show last sql error -} + print ''; + $sql2 = "SELECT ffd.tva_tx AS vatrate,"; + $sql2 .= " ffd.product_type AS product_type,"; + $sql2 .= " cc.label AS country,"; + for($i = 1; $i <= 12; $i ++) { + $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; + } + $sql2 .= " SUM(ffd.total_ht) as total"; + $sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; + $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; + $sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; + $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; + $sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; + $sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; + $sql.= " AND ff.fk_statut in (1,2)"; + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND ff.type IN (0,1,2,5)"; + } else { + $sql.= " AND ff.type IN (0,1,2,3,5)"; + } + $sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; + $sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; -print ''; -print ''; -print ''; -$i=0; -while($i < 12) -{ - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); - if ($j > 12) $j -= 12; - print ''; - $i++; -} -print ''; - -$sql2 = "SELECT ffd.tva_tx AS vatrate,"; -$sql2 .= " ffd.product_type AS product_type,"; -$sql2 .= " cc.label AS country,"; -for($i = 1; $i <= 12; $i ++) { - $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; -} -$sql2 .= " SUM(ffd.total_ht) as total"; -$sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; -$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; -$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; -$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; -$sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; -$sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; -$sql.= " AND ff.fk_statut in (1,2)"; -if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql.= " AND ff.type IN (0,1,2,5)"; -} else { - $sql.= " AND ff.type IN (0,1,2,3,5)"; -} -$sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; -$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; - -//print $sql2; -dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); -$resql2 = $db->query($sql2); -if ($resql2) { - $num = $db->num_rows($resql2); - $totalpermonth = array(); - while ( $obj = $db->fetch_object($resql2)) { - print ''; - if ($obj->product_type == 0) { - print ''; - } else { - print ''; + //print $sql2; + dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); + $resql2 = $db->query($sql2); + if ($resql2) { + $num = $db->num_rows($resql2); + $totalpermonth = array(); + while ( $obj = $db->fetch_object($resql2)) { + print ''; + if ($obj->product_type == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 0; $i < 12; $i++) { + $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); + if ($j > 12) $j -= 12; + $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); + print ''; + $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + } + print ''; + $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; } - print ''; + $db->free($resql2); + + // Total + print ''; + print ''; + print ''; for($i = 0; $i < 12; $i++) { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - $totalpermonth[$j]=(empty($totalpermonth[$j])?0:$totalpermonth[$j])+$obj->$monthj; + print ''; } - print ''; - $totalpermonth['total']=(empty($totalpermonth['total'])?0:$totalpermonth['total'])+$obj->total; + print ''; print ''; + } else { + print $db->lasterror(); // Show last sql error } - $db->free($resql2); - - // Total - print ''; - print ''; - print ''; - for($i = 0; $i < 12; $i++) { - $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START); - if ($j > 12) $j -= 12; - $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; - } - print ''; - print ''; -} else { - print $db->lasterror(); // Show last sql error -} -print "
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' .$obj->country . '' . price($obj->$monthj) . '' . price($obj->total) . '
' .$obj->country . '
' . price($obj->$monthj) . '' . price($totalpermonth[$j]) . '' . price($obj->total) . '' . price($totalpermonth['total']) . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . price($totalpermonth[$j]) . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . price($totalpermonth['total']) . '
' . $langs->trans("TotalHT") . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($j, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '
' . vatrate($obj->vatrate) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' . $obj->country . '' . price($obj->$monthj) . '' . price($obj->total) . '
' . $obj->country . '
' . price($obj->$monthj) . '' . price($totalpermonth[$j]) . '' . price($obj->total) . '' . price($totalpermonth['total']) . '
' . price($totalpermonth[$j]) . '' . price($totalpermonth['total']) . '
\n"; + print "\n"; } else { // $modecompta != 'CREANCES-DETTES' // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 8a97be4d252..5570b08435b 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -240,7 +240,7 @@ if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2,5)"; } else { - $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.type IN (0,1,2,3,5)"; } if ($date_start && $date_end) { $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; @@ -326,7 +326,7 @@ if ($modecompta == 'CREANCES-DETTES') // Array header print ""; -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Product"), $_SERVER["PHP_SELF"], "ref", @@ -336,7 +336,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans('Quantity'), $_SERVER["PHP_SELF"], "qty", @@ -346,7 +346,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Percentage"), $_SERVER["PHP_SELF"], "qty", @@ -356,7 +356,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans('AmountHT'), $_SERVER["PHP_SELF"], "amount", @@ -366,7 +366,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "amount_ttc", @@ -376,7 +376,7 @@ print_liste_field_titre( $sortfield, $sortorder ); -print_liste_field_titre( + print_liste_field_titre( $langs->trans("Percentage"), $_SERVER["PHP_SELF"], "amount_ttc", diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index cf1f49ae1a8..cf28a4cd5d6 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -172,7 +172,7 @@ if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; + if ($socid) $sql.= " AND f.fk_soc = ".$socid; } elseif ($modecompta=="RECETTES-DEPENSES") { @@ -187,7 +187,7 @@ elseif ($modecompta=="RECETTES-DEPENSES") $sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; + if ($socid) $sql.= " AND f.fk_soc = ".$socid; } elseif ($modecompta=="BOOKKEEPING") { diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index 921535bf20f..35772ee6f34 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -135,13 +135,15 @@ echo $this->control->tpl['ajax_selectcountry']; -control->tpl['contact_element'])) { ?> -control->tpl['contact_element'] as $element) { ?> - - - - - +control->tpl['contact_element'])) { + foreach ($this->control->tpl['contact_element'] as $element) { + print ''; + print ''.$element['linked_element_label'].''; + print ''.$element['linked_element_value'].''; + print ''; + } +} ?> trans("DolibarrLogin"); ?> diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index a9ccf9bff3d..d7cfe53b0bc 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -24,17 +24,14 @@ if (empty($conf) || ! is_object($conf)) $contact = $GLOBALS['objcanvas']->control->object; -?> - -control->tpl['showhead']; ?> +print "\n"; +echo $this->control->tpl['showhead']; -control->tpl['error'], $this->control->tpl['errors']); -?> -control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; ?> -control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> +if (! empty($this->control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; +if (! empty($this->control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> @@ -134,29 +131,27 @@ dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors'
-control->tpl['showend']; ?> +control->tpl['showend']; -societe_id)) { ?> -
+if (empty($user->societe_id)) { + print '
'; + if ($user->rights->societe->contact->creer) { + print ''.$langs->trans('Modify').''; + } -rights->societe->contact->creer) { ?> -">trans('Modify'); ?> - + if (! $this->control->tpl['user_id'] && $user->rights->user->user->creer) { + print ''.$langs->trans("CreateDolibarrLogin").''; + } -control->tpl['user_id'] && $user->rights->user->user->creer) { ?> -">trans("CreateDolibarrLogin"); ?> - + if ($user->rights->societe->contact->supprimer) { + print ''.$langs->trans('Delete').''; + } -rights->societe->contact->supprimer) { ?> -">trans('Delete'); ?> - - -

-
'; +} echo $this->control->tpl['actionstodo']; echo $this->control->tpl['actionsdone']; -?> - +print "\n"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 4fd98fab90c..08b2e8e1d41 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -695,7 +695,7 @@ else print $formcompany->select_state(GETPOST("state_id", 'alpha')?GETPOST("state_id", 'alpha'):$object->state_id, $object->country_code, 'state_id'); } else - { + { print $countrynotdefined; } print ''; @@ -1003,7 +1003,7 @@ else print ''; } - print $formcompany->select_state($object->state_id, isset($_POST["country_id"])?GETPOST("country_id"):$object->country_id, 'state_id'); + print $formcompany->select_state(GETPOSTISSET('state_id')?GETPOST('state_id', 'alpha'):$object->state_id, $object->country_code, 'state_id'); print ''; } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 4a6090d16f8..8b16e66ed92 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1218,11 +1218,11 @@ class Contact extends CommonObject //if ($this->civility_id) $label.= '
' . $langs->trans("Civility") . ': '.$this->civility_id; // TODO Translate cibilty_id code if (! empty($this->poste)) $label.= '
' . $langs->trans("Poste") . ': '.$this->poste; $label.= '
' . $langs->trans("EMail") . ': '.$this->email; - $phonelist=array(); - if ($this->phone_pro) $phonelist[]=$this->phone_pro; - if ($this->phone_mobile) $phonelist[]=$this->phone_mobile; - if ($this->phone_perso) $phonelist[]=$this->phone_perso; - $label.= '
' . $langs->trans("Phone") . ': '.join(', ', $phonelist); + $phonelist = array(); + if ($this->phone_pro) $phonelist[] = dol_print_phone($this->phone_pro, $this->country_code, $this->id, 0, '', ' ', 'phone'); + if ($this->phone_mobile) $phonelist[] = dol_print_phone($this->phone_mobile, $this->country_code, $this->id, 0, '', ' ', 'mobile'); + if ($this->phone_perso) $phonelist[] = dol_print_phone($this->phone_perso, $this->country_code, $this->id, 0, '', ' ', 'phone'); + $label.= '
' . $langs->trans("Phone") . ': '.implode(' ', $phonelist); $label.= '
' . $langs->trans("Address") . ': '.dol_format_address($this, 1, ' ', $langs); $url = DOL_URL_ROOT.'/contact/card.php?id='.$this->id; @@ -1320,23 +1320,24 @@ class Contact extends CommonObject // phpcs:enable global $langs; - if (empty($this->status) || empty($this->statusshort)) - { - $this->labelstatus[0] = 'ActivityCeased'; - $this->labelstatusshort[0] = 'ActivityCeased'; - $this->labelstatus[5] = 'ActivityCeased'; - $this->labelstatusshort[5] = 'ActivityCeased'; - $this->labelstatus[1] = 'InActivity'; - $this->labelstatusshort[1] = 'InActivity'; - $this->labelstatus[4] = 'InActivity'; - $this->labelstatusshort[4] = 'InActivity'; - } + $labelstatus = array( + 0 => 'ActivityCeased', + 1 => 'InActivity', + 4 => 'InActivity', + 5 => 'ActivityCeased', + ); + $labelstatusshort = array( + 0 => 'ActivityCeased', + 1 => 'InActivity', + 4 => 'InActivity', + 5 => 'ActivityCeased', + ); $statusType = 'status4'; if ($status==0 || $status==5) $statusType = 'status5'; - $label = $langs->trans($this->labelstatus[$status]); - $labelshort = $langs->trans($this->labelstatusshort[$status]); + $label = $langs->trans($labelstatus[$status]); + $labelshort = $langs->trans($labelstatusshort[$status]); return dolGetStatus($label, $labelshort, '', $statusType, $mode); } diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index c82795b9449..00817ee5799 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -151,7 +151,7 @@ if ($object->thirdparty->fournisseur) if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']=$langs->transnoentitiesnoconv('SuppliersOrders'); // There no contact type for supplier proposals -// if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); + // if ($conf->fournisseur->enabled && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); } print ''; @@ -298,7 +298,7 @@ if (!empty($sql_select)) $sql.= " "; if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label"; $sql.= " FROM "/*.MAIN_DB_PREFIX."societe as s, "*/.$tables_from; -// if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; + // if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; $sql.= $where; $sql.= dolSqlDateFilter($dateprint, 0, $month, $year); if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index ad8bbb68e5f..1dbc22d1a51 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -63,8 +63,8 @@ $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (! empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield=$conf->global->MAIN_DOC_SORT_FIELD; } - if (! empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder=$conf->global->MAIN_DOC_SORT_ORDER; } +if (! empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield=$conf->global->MAIN_DOC_SORT_FIELD; } +if (! empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder=$conf->global->MAIN_DOC_SORT_ORDER; } if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 13c1a992a37..60232a052af 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -292,7 +292,7 @@ $sql.= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, // socialnetworks->>'$.facebook' as facebook $sql.= " p.socialnetworks,"; $sql.= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; -$sql.= " co.code as country_code"; +$sql.= " co.label as country, co.code as country_code"; // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -680,9 +680,9 @@ if (! empty($arrayfields['p.thirdparty']['checked'])) if (! empty($arrayfields['p.priv']['checked'])) { print ''; - $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); - print $form->selectarray('search_priv', $selectarray, $search_priv, 1); - print ''; + $selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate")); + print $form->selectarray('search_priv', $selectarray, $search_priv, 1); + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -799,6 +799,8 @@ while ($i < min($num, $limit)) $contactstatic->zip=$obj->zip; $contactstatic->town=$obj->town; $contactstatic->socialnetworks = $arraysocialnetworks; + $contactstatic->country = $obj->country; + $contactstatic->country_code = $obj->country_code; // ID if (! empty($arrayfields['p.rowid']['checked'])) @@ -911,9 +913,9 @@ while ($i < min($num, $limit)) print ''; if ($obj->socid) { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); } else print ' '; diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index e96425a0dae..df1629b46a6 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -164,19 +164,20 @@ if ($id > 0) $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->contrat->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index ef57c84443b..3a8e4f99a65 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -331,9 +331,8 @@ if (empty($reshook)) // Extrafields $array_options = array(); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if - // trigger used - { + // For avoid conflicts if trigger used + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_options = $lines[$i]->array_options; } @@ -445,13 +444,13 @@ if (empty($reshook)) $error++; } - $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); - $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); - if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) - { - setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); - $error++; - } + $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year')); + $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year')); + if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) + { + setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors'); + $error++; + } // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); @@ -532,7 +531,7 @@ if (empty($reshook)) $pu_ht = price2num($pu_ttc / (1 + ($tmpvat/100)), 'MU'); } else - { + { $pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU'); } } @@ -728,9 +727,9 @@ if (empty($reshook)) $objectline->pa_ht=$pa_ht; if ($fk_unit > 0) { - $objectline->fk_unit = GETPOST('unit'); + $objectline->fk_unit = GETPOST('unit'); } else { - $objectline->fk_unit = null; + $objectline->fk_unit = null; } // Extrafields @@ -1419,19 +1418,20 @@ else $morehtmlref.='
'.$langs->trans('Project') . ' '; if ($user->rights->contrat->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -2254,7 +2254,7 @@ $db->close(); if (! empty($conf->margin->enabled) && $action == 'editline') { // TODO Why this ? To manage margin on contracts ? -?> + ?> - * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2015-2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -861,9 +861,9 @@ class Contrat extends CommonObject // multilangs if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($objp->fk_product) && ! empty($loadalsotranslation)) { - $line = new Product($this->db); - $line->fetch($objp->fk_product); - $line->getMultiLangs(); + $line = new Product($this->db); + $line->fetch($objp->fk_product); + $line->getMultiLangs(); } $this->lines[$pos] = $line; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index fac71516e99..81c0b13449b 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -705,17 +705,18 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['status']['checked'])) { - print ''; - if ($obj->cstatut == 0) // If contract is draft, we say line is also draft - { - print $contractstatic->LibStatut(0, 5); - } - else - { - print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0); - } - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if ($obj->cstatut == 0) + { + // If contract is draft, we say line is also draft + print $contractstatic->LibStatut(0, 5); + } + else + { + print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0); + } + print ''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index bda12ea87cb..b52a6939882 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -23,11 +23,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Contract"); ?> getNomUrl(1); ?> date_contrat, 'day'); ?> rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) - { - $totalcontrat = 0; - foreach ($objectlink->lines as $linecontrat) { - $totalcontrat = $totalcontrat + $linecontrat->total_ht; - $total = $total + $linecontrat->total_ht; - } - echo price($totalcontrat); - } ?> + // Price of contract is not shown by default because a contract is a list of service with + // start and end date that change with time andd that may be different that the period of reference for price. + // So price of a contract does often means nothing. Prices is on the different invoices done on same contract. + if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) + { + $totalcontrat = 0; + foreach ($objectlink->lines as $linecontrat) { + $totalcontrat = $totalcontrat + $linecontrat->total_ht; + $total = $total + $linecontrat->total_ht; + } + echo price($totalcontrat); + } ?> getLibStatut(7); ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + '.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - + +print "\n"; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 72ad67db52e..dcb8f75c637 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -108,7 +108,6 @@ if ($action == 'update' && ! empty($permissiontoadd)) { if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - var_dump($object->fields[$key]['type']); // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'none'); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 5402236f47e..92bc2ff18f6 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -57,12 +57,12 @@ if ($action == 'builddoc' && $permissioncreate) // Special case to force bank account //if (property_exists($object, 'fk_bank')) //{ - if (GETPOST('fk_bank', 'int')) { - // this field may come from an external module - $object->fk_bank = GETPOST('fk_bank', 'int'); - } elseif (! empty($object->fk_account)) { - $object->fk_bank = $object->fk_account; - } + if (GETPOST('fk_bank', 'int')) { + // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank', 'int'); + } elseif (! empty($object->fk_account)) { + $object->fk_bank = $object->fk_account; + } //} $outputlangs = $langs; diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 760a54bc7b2..90c93f6177b 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -81,78 +81,79 @@ elseif (GETPOST('linkit', 'none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete file/link if ($action == 'confirm_deletefile' && $confirm == 'yes') { - $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - if (GETPOST('section', 'alpha')) // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir + $urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + if (GETPOST('section', 'alpha')) { + // For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir + $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; + } + else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + { + $urlfile=basename($urlfile); + $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; + if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile; + } + $linkid = GETPOST('linkid', 'int'); + + if ($urlfile) { + // delete of a file + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine + $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) + + $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null)); + if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null)); // Delete file using old path + + // Si elle existe, on efface la vignette + if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) { - $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; - } - else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. - { - $urlfile=basename($urlfile); - $file = $upload_dir . (preg_match('/\/$/', $upload_dir) ? '' : '/') . $urlfile; - if (! empty($upload_dirold)) $fileold = $upload_dirold . "/" . $urlfile; - } - $linkid = GETPOST('linkid', 'int'); - - if ($urlfile) // delete of a file - { - $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine - $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image) - - $ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null)); - if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null)); // Delete file using old path - - // Si elle existe, on efface la vignette - if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) + $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) { - $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { - dol_delete_file($dirthumb.$photo_vignette); - } - - $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); - if (file_exists(dol_osencode($dirthumb.$photo_vignette))) - { - dol_delete_file($dirthumb.$photo_vignette); - } + dol_delete_file($dirthumb.$photo_vignette); } - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); + $photo_vignette=basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]); + if (file_exists(dol_osencode($dirthumb.$photo_vignette))) + { + dol_delete_file($dirthumb.$photo_vignette); + } } - elseif ($linkid) // delete of external link - { - require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; - $link = new Link($db); - $link->fetch($linkid); - $res = $link->delete($user); - $langs->load('link'); - if ($res > 0) { - setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); + } + } + elseif ($linkid) // delete of external link + { + require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; + $link = new Link($db); + $link->fetch($linkid); + $res = $link->delete($user); + + $langs->load('link'); + if ($res > 0) { + setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); + } else { + if (count($link->errors)) { + setEventMessages('', $link->errors, 'errors'); } else { - if (count($link->errors)) { - setEventMessages('', $link->errors, 'errors'); - } else { - setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); - } + setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); } } + } - if (is_object($object) && $object->id > 0) - { - if ($backtopage) - { - header('Location: ' . $backtopage); - exit; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):'').(!empty($withproject)?'&withproject=1':'')); - exit; - } + if (is_object($object) && $object->id > 0) { + if ($backtopage) { + header('Location: ' . $backtopage); + exit; } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha')?'§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')):'').(!empty($withproject)?'&withproject=1':'')); + exit; + } + } } elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 7d8d621ff92..febcba244c0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1085,7 +1085,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se } else { - setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); + setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); } } } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php new file mode 100644 index 00000000000..b4ac04b3051 --- /dev/null +++ b/htdocs/core/boxes/box_boms.php @@ -0,0 +1,182 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_boms.php + * \ingroup bom + * \brief Widget for latest modified BOM + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last orders + */ +class box_boms extends ModeleBoxes +{ + public $boxcode="lastboms"; + public $boximg="object_bom"; + public $boxlabel="BoxTitleLatestModifiedBoms"; + public $depends = array("bom"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->bom->read); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + $bomstatic = new Bom($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max)); + + if ($user->rights->bom->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql.= ", c.rowid"; + $sql.= ", c.date_creation"; + $sql.= ", c.tms"; + $sql.= ", c.ref"; + $sql.= ", c.status"; + $sql.= ", c.fk_user_valid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= ", ".MAIN_DB_PREFIX."bom_bom as c"; + $sql.= " WHERE c.fk_product = p.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " ORDER BY c.tms DESC, c.ref DESC"; + $sql.= " ".$this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); + $bomstatic->id = $objp->rowid; + $bomstatic->ref = $objp->ref; + $bomstatic->id = $objp->socid; + $bomstatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $bomstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); + + if (! empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'asis' => 1, + ); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $bomstatic->LibStatut($objp->status, 3), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 00e3d54386c..327f06fc0c9 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -21,7 +21,7 @@ /** * \file htdocs/core/boxes/box_commandes.php * \ingroup commande - * \brief Module de generation de l'affichage de la box commandes + * \brief Widget for latest sale orders */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 82db6c9f240..09e33c5f6a8 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -86,7 +86,9 @@ class box_contacts extends ModeleBoxes $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail"; $sql.= ", s.nom as socname, s.name_alias, s.email as semail"; $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; + $sql.= ", co.label as country, co.code as country_code"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; @@ -121,6 +123,8 @@ class box_contacts extends ModeleBoxes $contactstatic->address = $objp->address; $contactstatic->zip = $objp->zip; $contactstatic->town = $objp->town; + $contactstatic->country = $objp->country; + $contactstatic->country_code = $objp->country_code; $societestatic->id = $objp->fk_soc; $societestatic->name = $objp->socname; diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php new file mode 100644 index 00000000000..32ae864fc2f --- /dev/null +++ b/htdocs/core/boxes/box_mos.php @@ -0,0 +1,182 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_mos.php + * \ingroup mrp + * \brief Widget for latest modified MOs + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last orders + */ +class box_mos extends ModeleBoxes +{ + public $boxcode="lastmos"; + public $boximg="object_mrp"; + public $boxlabel="BoxTitleLatestModifiedMos"; + public $depends = array("mrp"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->bom->read); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + $mostatic = new Mo($this->db); + $productstatic = new Product($this->db); + $userstatic = new User($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max)); + + if ($user->rights->mrp->read) + { + $sql = "SELECT p.ref as product_ref"; + $sql.= ", c.rowid"; + $sql.= ", c.date_creation"; + $sql.= ", c.tms"; + $sql.= ", c.ref"; + $sql.= ", c.status"; + //$sql.= ", c.fk_user_valid"; + $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; + $sql.= ", ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql.= " WHERE c.fk_product = p.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " ORDER BY c.tms DESC, c.ref DESC"; + $sql.= " ".$this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datem=$this->db->jdate($objp->tms); + $mostatic->id = $objp->rowid; + $mostatic->ref = $objp->ref; + $mostatic->id = $objp->socid; + $mostatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $mostatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $productstatic->getNomUrl(1), + 'asis' => 1, + ); + + if (! empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) { + if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (($objp->fk_user_valid > 0)?$userstatic->getNomUrl(1):''), + 'asis' => 1, + ); + } + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, 'day'), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $mostatic->LibStatut($objp->status, 3), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedOrders")); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 37e8270d449..cfdb09c527e 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -54,12 +54,12 @@ class Canvas public $control; // Initialized by getCanvas with controller instance - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param string $actiontype Action type ('create', 'view', 'edit', 'list') - */ + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $actiontype Action type ('create', 'view', 'edit', 'list') + */ public function __construct($db, $actiontype = 'view') { $this->db = $db; diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index edbceec50fd..0934d85b3e7 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -171,16 +171,16 @@ class Ccountry // extends CommonObject public function fetch($id, $code = '', $code_iso = '') { global $langs; - $sql = "SELECT"; + $sql = "SELECT"; $sql.= " t.rowid,"; $sql.= " t.code,"; $sql.= " t.code_iso,"; $sql.= " t.label,"; $sql.= " t.active"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; - if ($id) $sql.= " WHERE t.rowid = ".$id; - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; - elseif ($code_iso) $sql.= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_country as t"; + if ($id) $sql.= " WHERE t.rowid = ".$id; + elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($code_iso) $sql.= " WHERE t.code_iso = '".$this->db->escape($code_iso)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 98a40c73c0b..ec27b83e0a0 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -154,7 +154,7 @@ abstract class CommonInvoice extends CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { // TODO - return 0; + return 0; } require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dd1076cc87c..6adbba4366a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2017 ATM Consulting * Copyright (C) 2017-2019 Nicolas ZABOURI * Copyright (C) 2017 Rui Strecht - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -4612,259 +4612,258 @@ abstract class CommonObject */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams = null) { - global $conf, $langs, $user, $hookmanager; + global $conf, $langs, $user, $hookmanager, $action; $srctemplatepath=''; $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if(empty($reshook)) + if (empty($reshook)) { - dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); + dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs)?$outputlangs->defaultlang:'null')); - // Increase limit for PDF build - $err=error_reporting(); - error_reporting(0); - @set_time_limit(120); - error_reporting($err); + // Increase limit for PDF build + $err=error_reporting(); + error_reporting(0); + @set_time_limit(120); + error_reporting($err); - // If selected model is a filename template (then $modele="modelname" or "modelname:filename") - $tmp=explode(':', $modele, 2); - if (! empty($tmp[1])) - { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; - } + // If selected model is a filename template (then $modele="modelname" or "modelname:filename") + $tmp=explode(':', $modele, 2); + if (! empty($tmp[1])) + { + $modele=$tmp[0]; + $srctemplatepath=$tmp[1]; + } - // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - foreach(array('doc','pdf') as $prefix) - { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php - else $file = $prefix."_".$modele.".modules.php"; + // Search template files + $file=''; + $classname=''; + $filefound=0; + $dirmodels=array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + foreach(array('doc','pdf') as $prefix) + { + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php + else $file = $prefix."_".$modele.".modules.php"; - // On verifie l'emplacement du modele - $file=dol_buildpath($reldir.$modelspath.$file, 0); - if (file_exists($file)) - { - $filefound=1; - $classname=$prefix.'_'.$modele; - break; - } - } - if ($filefound) break; - } + // On verifie l'emplacement du modele + $file=dol_buildpath($reldir.$modelspath.$file, 0); + if (file_exists($file)) + { + $filefound=1; + $classname=$prefix.'_'.$modele; + break; + } + } + if ($filefound) break; + } - // If generator was found - if ($filefound) - { - global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. + // If generator was found + if ($filefound) + { + global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. - require_once $file; + require_once $file; - $obj = new $classname($this->db); + $obj = new $classname($this->db); - // If generator is ODT, we must have srctemplatepath defined, if not we set it. - if ($obj->type == 'odt' && empty($srctemplatepath)) - { - $varfortemplatedir=$obj->scandir; - if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) - { - $dirtoscan=$conf->global->$varfortemplatedir; + // If generator is ODT, we must have srctemplatepath defined, if not we set it. + if ($obj->type == 'odt' && empty($srctemplatepath)) + { + $varfortemplatedir=$obj->scandir; + if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) + { + $dirtoscan=$conf->global->$varfortemplatedir; - $listoffiles=array(); + $listoffiles=array(); - // Now we add first model found in directories scanned - $listofdir=explode(',', $dirtoscan); - foreach($listofdir as $key => $tmpdir) - { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } - if (is_dir($tmpdir)) - { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); - } - } + // Now we add first model found in directories scanned + $listofdir=explode(',', $dirtoscan); + foreach($listofdir as $key => $tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (! $tmpdir) { unset($listofdir[$key]); continue; } + if (is_dir($tmpdir)) + { + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + } + } - if (count($listoffiles)) - { - foreach($listoffiles as $record) - { - $srctemplatepath=$record['fullname']; - break; - } - } - } + if (count($listoffiles)) + { + foreach($listoffiles as $record) + { + $srctemplatepath=$record['fullname']; + break; + } + } + } - if (empty($srctemplatepath)) - { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; - return -1; - } - } + if (empty($srctemplatepath)) + { + $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; + return -1; + } + } - if ($obj->type == 'odt' && ! empty($srctemplatepath)) - { - if (! dol_is_file($srctemplatepath)) - { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; - return -1; - } - } + if ($obj->type == 'odt' && ! empty($srctemplatepath)) + { + if (! dol_is_file($srctemplatepath)) + { + $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; + return -1; + } + } - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; - if (in_array(get_class($this), array('Adherent'))) - { - $arrayofrecords = array(); // The write_file of templates of adherent class need this var - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); - } - else - { - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); - } - // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. + if (in_array(get_class($this), array('Adherent'))) + { + $arrayofrecords = array(); // The write_file of templates of adherent class need this var + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); + } + else + { + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + } + // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. - if ($resultwritefile > 0) - { - $outputlangs->charset_output=$sav_charset_output; + if ($resultwritefile > 0) + { + $outputlangs->charset_output=$sav_charset_output; - // We delete old preview - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_delete_preview($this); + // We delete old preview + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_delete_preview($this); - // Index file in database - if (! empty($obj->result['fullpath'])) - { - $destfull = $obj->result['fullpath']; - $upload_dir = dirname($destfull); - $destfile = basename($destfull); - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); + // Index file in database + if (! empty($obj->result['fullpath'])) + { + $destfull = $obj->result['fullpath']; + $upload_dir = dirname($destfull); + $destfile = basename($destfull); + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir); - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir - { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($destfile); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); - // Set the public "share" key - $setsharekey = false; - if ($this->element == 'propal') - { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok - if ($useonlinesignature) $setsharekey=true; - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; - } - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; - } - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { - $setsharekey=true; - } + // Set the public "share" key + $setsharekey = false; + if ($this->element == 'propal') + { + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + if ($useonlinesignature) $setsharekey=true; + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + } + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } - if ($setsharekey) - { - if (empty($ecmfile->share)) // Because object not found or share not set yet - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $ecmfile->share = getRandomPassword(true); - } - } + if ($setsharekey) { + if (empty($ecmfile->share)) // Because object not found or share not set yet + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + } - if ($result > 0) - { - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->update($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } - else - { - $ecmfile->entity = $conf->entity; - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $ecmfile->src_object_type = $this->table_element; - $ecmfile->src_object_id = $this->id; + if ($result > 0) + { + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->update($user); + if ($result < 0) { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + else + { + $ecmfile->entity = $conf->entity; + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $ecmfile->src_object_type = $this->table_element; + $ecmfile->src_object_id = $this->id; - $result = $ecmfile->create($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } + $result = $ecmfile->create($user); + if ($result < 0) { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } - /*$this->result['fullname']=$destfull; - $this->result['filepath']=$ecmfile->filepath; - $this->result['filename']=$ecmfile->filename;*/ - //var_dump($obj->update_main_doc_field);exit; + /*$this->result['fullname']=$destfull; + $this->result['filepath']=$ecmfile->filepath; + $this->result['filename']=$ecmfile->filename;*/ + //var_dump($obj->update_main_doc_field);exit; - // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) - $update_main_doc_field=0; - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; - if ($update_main_doc_field && ! empty($this->table_element)) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql.= ' WHERE rowid = '.$this->id; + // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) + $update_main_doc_field=0; + if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; + if ($update_main_doc_field && ! empty($this->table_element)) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'"; + $sql.= ' WHERE rowid = '.$this->id; - $resql = $this->db->query($sql); - if (! $resql) dol_print_error($this->db); - else - { - $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; - } - } - } - } - else - { - dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); - } + $resql = $this->db->query($sql); + if (! $resql) { + dol_print_error($this->db); + } else { + $this->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; + } + } + } + } + else + { + dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); + } - // Success in building document. We build meta file. - dol_meta_create($this); + // Success in building document. We build meta file. + dol_meta_create($this); - return 1; - } - else - { - $outputlangs->charset_output=$sav_charset_output; - dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); - return -1; - } - } - else - { - $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); - dol_print_error('', $this->error); - return -1; - } + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); + return -1; + } + } + else + { + $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file); + dol_print_error('', $this->error); + return -1; + } } else return $reshook; } @@ -6070,18 +6069,19 @@ abstract class CommonObject $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18); } } - if (empty($labeltoshow)) + if (empty($labeltoshow)) { $labeltoshow = '(not defined)'; + } - if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { - $data[$obj->rowid]=$labeltoshow; - } - - if (! empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName . ':' . $obj->{$parentField}; - } - + if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { $data[$obj->rowid]=$labeltoshow; + } + + if (! empty($InfoFieldList[3]) && $parentField) { + $parent = $parentName . ':' . $obj->{$parentField}; + } + + $data[$obj->rowid]=$labeltoshow; } $i ++; diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 6c6b14ee4e4..83450ee6462 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -182,16 +182,16 @@ abstract class CommonStickerGenerator for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) { for($j=$i;$j<=($i+$Pointilles);$j++) { if($j<=($x2-1)) { - $pdf->Line($j, $y1, $j+1, $y1); // on trace le pointill? du haut, point par point - $pdf->Line($j, $y2, $j+1, $y2); // on trace le pointill? du bas, point par point + $pdf->Line($j, $y1, $j+1, $y1); // on trace le pointill? du haut, point par point + $pdf->Line($j, $y2, $j+1, $y2); // on trace le pointill? du bas, point par point } } } for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) { for($j=$i;$j<=($i+$Pointilles);$j++) { if($j<=($y2-1)) { - $pdf->Line($x1, $j, $x1, $j+1); // on trace le pointill? du haut, point par point - $pdf->Line($x2, $j, $x2, $j+1); // on trace le pointill? du bas, point par point + $pdf->Line($x1, $j, $x1, $j+1); // on trace le pointill? du haut, point par point + $pdf->Line($x2, $j, $x2, $j+1); // on trace le pointill? du bas, point par point } } } diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index 19588333fcb..cc87a791c0d 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -392,10 +392,10 @@ class CoreObject extends CommonObject */ public function setDate($field, $date) { - if (empty($date)) - { - $this->{$field} = 0; - } + if (empty($date)) + { + $this->{$field} = 0; + } else { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 5048e74b711..c790d89e407 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -252,7 +252,7 @@ class Ctyperesource $sql .= $this->db->order($sortfield, $sortorder); } if (!empty($limit)) { - $sql .= ' ' . $this->db->plimit($limit, $offset); + $sql .= ' ' . $this->db->plimit($limit, $offset); } $resql = $this->db->query($sql); diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index cc6172e441a..a0879160727 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -157,7 +157,7 @@ class DolEditor $fullpage=false; if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) { - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all } $found=0; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 07554671497..461867041eb 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -944,9 +944,9 @@ class DolGraph if (! empty($this->title)) $this->stringtoshow.='
'.$this->title.'
'; if (! empty($this->shownographyet)) { - $this->stringtoshow.='
'; - $this->stringtoshow.='
'.$langs->trans("NotEnoughDataYet").'
'; - return; + $this->stringtoshow.='
'; + $this->stringtoshow.='
'.$langs->trans("NotEnoughDataYet").'
'; + return; } $this->stringtoshow.='
'."\n"; diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 94dea68ed67..f944ccdc0c0 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -248,12 +248,12 @@ class Fiscalyear extends CommonObject } } - /** - * Delete record - * - * @param int $id Id of record to delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete record + * + * @param int $id Id of record to delete + * @return int <0 if KO, >0 if OK + */ public function delete($id) { $this->db->begin(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ca285642b2a..7f1c2cbee50 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -227,14 +227,14 @@ class Form } elseif (preg_match('/^select;/', $typeofdata)) { - $arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata)); - foreach($arraydata as $val) - { - $tmp=explode(':', $val); - $tmpkey=str_replace('|', ':', $tmp[0]); - $arraylist[$tmpkey]=$tmp[1]; - } - $ret.=$this->selectarray($htmlname, $arraylist, $value); + $arraydata=explode(',', preg_replace('/^select;/', '', $typeofdata)); + foreach($arraydata as $val) + { + $tmp=explode(':', $val); + $tmpkey=str_replace('|', ':', $tmp[0]); + $arraylist[$tmpkey]=$tmp[1]; + } + $ret.=$this->selectarray($htmlname, $arraylist, $value); } elseif (preg_match('/^ckeditor/', $typeofdata)) { @@ -5458,9 +5458,9 @@ class Form dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."', autoclose: true, todayHighlight: true,"; - if (! empty($conf->dol_use_jmobile)) - { - $retstring.=" + if (! empty($conf->dol_use_jmobile)) + { + $retstring.=" beforeShow: function (input, datePicker) { input.disabled = true; }, @@ -5468,16 +5468,16 @@ class Form this.disabled = false; }, "; - } - // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php - if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) - { + } + // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php + if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) + { $retstring.=" showOn: 'button', buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png', buttonImageOnly: true"; - } - $retstring.=" + } + $retstring.=" }) });"; $retstring.=""; } @@ -5835,10 +5835,11 @@ class Form * @param string $moreparams More params provided to ajax call * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param int $disabled 1=Html component is disabled + * @param string $selected_input_value Value of preselected input text (for use with ajax) * @return string Return HTML string * @see selectForFormsList() select_thirdparty */ - public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0) + public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') { global $conf, $user; @@ -5870,20 +5871,28 @@ class Form $confkeyforautocompletemode=strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT dol_syslog(get_class($this)."::selectForForms object->filter=".$objecttmp->filter, LOG_DEBUG); - $out=''; if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->$confkeyforautocompletemode) && ! $forcecombo) { - $objectdesc=$classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; + // No immediate load of all database + $placeholder=''; + if ($preselectedvalue && empty($selected_input_value)) + { + $objecttmp->fetch($preselectedvalue); + $selected_input_value=($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref); + //unset($objecttmp); + } + + $objectdesc=$classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter; $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; // No immediate load of all database - $urloption='htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.($moreparams?$moreparams:''); + $urloption='htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.'&filter='.urlencode($objecttmp->filter).($moreparams?$moreparams:''); // Activate the auto complete using ajax call. $out.= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); $out.= ''; if ($placeholder) $placeholder=' placeholder="'.$placeholder.'"'; - $out.= ''; + $out.= ''; } else { @@ -6563,19 +6572,19 @@ class Form foreach($array as $key => $val) { - /* var_dump($val); + /* var_dump($val); var_dump(array_key_exists('enabled', $val)); var_dump(!$val['enabled']);*/ - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) - { - unset($array[$key]); // We don't want this field - continue; - } - if ($val['label']) - { - $lis.='
  • '; - $listcheckedstring.=(empty($val['checked'])?'':$key.','); - } + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) + { + unset($array[$key]); // We don't want this field + continue; + } + if ($val['label']) + { + $lis.='
  • '; + $listcheckedstring.=(empty($val['checked'])?'':$key.','); + } } $out =' @@ -6970,7 +6979,7 @@ class Form if (! empty($conf->use_javascript_ajax)) { - print ' + print ' - '; + '; } return $linktoelem; @@ -7017,7 +7026,7 @@ class Form $resultyesno .= ''."\n"; } else - { + { $selected=(($useempty && $value != '0' && $value != 'no')?'':' selected'); $resultyesno .= ''."\n"; $resultyesno .= ''."\n"; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 3dc095c91da..02a0a29b428 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -45,11 +45,11 @@ class FormAccounting extends Form */ public $error=''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ + /** + * Constructor + * + * @param DoliDB $db Database handler + */ public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 87d367e23f1..6740ecb7bbf 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -76,13 +76,12 @@ class FormContract if ($socid > 0) { // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. - if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) - $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; - elseif ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') - { - $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { + $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; + } elseif ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { + $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; $sql.= " OR c.fk_soc IS NULL)"; - } + } } if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; $sql.= " ORDER BY c.ref "; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 9981bb269a1..66f05010662 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -41,9 +41,21 @@ class FormMail extends Form */ public $db; - public $withform; // 1=Include HTML form tag and show submit button, 0=Do not include form tag and submit button, -1=Do not include form tag but include submit button + /** + * @var int 1 = Include HTML form tag and show submit button + * 0 = Do not include form tag and submit button + * -1 = Do not include form tag but include submit button + */ + public $withform; + /** + * @var string name from + */ public $fromname; + + /** + * @var string email from + */ public $frommail; /** @@ -52,10 +64,15 @@ class FormMail extends Form public $fromtype; /** - * @var int ID + * @var int from ID */ public $fromid; + /** + * @var int also from robot + */ + public $fromalsorobot; + /** * @var string thirdparty etc */ @@ -66,10 +83,29 @@ class FormMail extends Form */ public $toid; + /** + * @var string replyto name + */ public $replytoname; + + /** + * @var string replyto email + */ public $replytomail; + + /** + * @var string to name + */ public $toname; + + /** + * @var string to email + */ public $tomail; + + /** + * @var string trackid + */ public $trackid; public $withsubstit; // Show substitution array diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 24242485339..69525c0f134 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1292,7 +1292,7 @@ class FormOther $resultautomanual .= ''."\n"; } else - { + { $selected=(($useempty && $value != '0' && $value != 'manual')?'':' selected'); $resultautomanual .= ''."\n"; $resultautomanual .= ''."\n"; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 92b551db918..b22473ec483 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1362,12 +1362,12 @@ class Ldap } } - /** - * UserAccountControl Flgs to more human understandable form... - * - * @param string $uacf UACF - * @return void - */ + /** + * UserAccountControl Flgs to more human understandable form... + * + * @param string $uacf UACF + * @return void + */ public function parseUACF($uacf) { //All flags array @@ -1408,12 +1408,12 @@ class Ldap return($retval); } - /** - * SamAccountType value to text - * - * @param string $samtype SamType - * @return string Sam string - */ + /** + * SamAccountType value to text + * + * @param string $samtype SamType + * @return string Sam string + */ public function parseSAT($samtype) { $stypes = array( diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 1b9c9225258..5a63ad0efd6 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -137,22 +137,21 @@ class Menubase // an insert with a forced id. if (in_array($this->db->type, array('pgsql'))) { - $sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu"; - $resqlrowid=$this->db->query($sql); - if ($resqlrowid) - { - $obj=$this->db->fetch_object($resqlrowid); - $maxrowid=$obj->maxrowid; + $sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu"; + $resqlrowid=$this->db->query($sql); + if ($resqlrowid) { + $obj=$this->db->fetch_object($resqlrowid); + $maxrowid=$obj->maxrowid; - // Max rowid can be empty if there is no record yet - if(empty($maxrowid)) $maxrowid=1; + // Max rowid can be empty if there is no record yet + if(empty($maxrowid)) $maxrowid=1; - $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; - //print $sql; exit; - $resqlrowidset=$this->db->query($sql); - if (! $resqlrowidset) dol_print_error($this->db); - } - else dol_print_error($this->db); + $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")"; + //print $sql; exit; + $resqlrowidset=$this->db->query($sql); + if (! $resqlrowidset) dol_print_error($this->db); + } + else dol_print_error($this->db); } // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index f9482e843c3..3520b5f1c3c 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -571,7 +571,7 @@ class Notify } } else - { + { dol_syslog("No notification sent for ".$sendto." because email is empty"); } $i++; diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index c884f4bd7da..e4fe7843d1d 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -556,8 +556,8 @@ class SimpleOpenID return false; } else - { - dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); + { + dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); $this->SetOpenIDServer($server); return $server; } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 51a77b87c30..2c489b25181 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -220,11 +220,10 @@ class DoliDBMssql extends DoliDB */ public function close() { - if ($this->db) - { - if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR); - $this->connected=false; - return mssql_close($this->db); + if ($this->db) { + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR); + $this->connected=false; + return mssql_close($this->db); } return false; } @@ -407,15 +406,15 @@ class DoliDBMssql extends DoliDB // Inserer la date en parametre et le reste de la requete $query = $newquery." DATEPART(week, ".$extractvalue.$endofquery; } - if (preg_match('/^insert\h+(?:INTO)?\h*(\w+?)\h*\(.*\b(?:row)?id\b.*\)\h+VALUES/i', $query, $matches)) - { - //var_dump($query); - //var_dump($matches); - //if (stripos($query,'llx_c_departements') !== false) var_dump($query); - $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;'; - @mssql_query($sql, $this->db); - $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;'; - } + if (preg_match('/^insert\h+(?:INTO)?\h*(\w+?)\h*\(.*\b(?:row)?id\b.*\)\h+VALUES/i', $query, $matches)) + { + //var_dump($query); + //var_dump($matches); + //if (stripos($query,'llx_c_departements') !== false) var_dump($query); + $sql='SET IDENTITY_INSERT ['.trim($matches[1]).'] ON;'; + @mssql_query($sql, $this->db); + $post_query='SET IDENTITY_INSERT ['.trim($matches[1]).'] OFF;'; + } } //print ""; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 2347d3d77e5..2388b60c7e1 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; class DoliDBPgsql extends DoliDB { //! Database type - public $type='pgsql'; // Name of manager + public $type='pgsql'; // Name of manager //! Database label const LABEL='PostgreSQL'; // Label of manager //! Charset @@ -174,9 +174,9 @@ class DoliDBPgsql extends DoliDB if ($type == 'auto') { - if (preg_match('/ALTER TABLE/i', $line)) $type='dml'; - elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml'; - elseif (preg_match('/DROP TABLE/i', $line)) $type='dml'; + if (preg_match('/ALTER TABLE/i', $line)) $type='dml'; + elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml'; + elseif (preg_match('/DROP TABLE/i', $line)) $type='dml'; } $line=preg_replace('/ as signed\)/i', ' as integer)', $line); @@ -457,8 +457,8 @@ class DoliDBPgsql extends DoliDB $resql=$this->query('SHOW server_version'); if ($resql) { - $liste=$this->fetch_array($resql); - return $liste['server_version']; + $liste=$this->fetch_array($resql); + return $liste['server_version']; } return ''; } @@ -483,9 +483,9 @@ class DoliDBPgsql extends DoliDB { if ($this->db) { - if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR); - $this->connected=false; - return pg_close($this->db); + if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened, LOG_ERR); + $this->connected=false; + return pg_close($this->db); } return false; } @@ -955,10 +955,10 @@ class DoliDBPgsql extends DoliDB $result = $this->query($sql); if ($result) { - while($row = $this->fetch_row($result)) - { + while($row = $this->fetch_row($result)) + { $infotables[] = $row; - } + } } return $infotables; } @@ -1127,21 +1127,24 @@ class DoliDBPgsql extends DoliDB $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql .= $field_desc['type']; if (preg_match("/^[^\s]/i", $field_desc['value'])) - if (! in_array($field_desc['type'], array('int','date','datetime'))) - { - $sql.= "(".$field_desc['value'].")"; - } + if (! in_array($field_desc['type'], array('int','date','datetime'))) + { + $sql.= "(".$field_desc['value'].")"; + } if (preg_match("/^[^\s]/i", $field_desc['attribute'])) $sql .= " ".$field_desc['attribute']; if (preg_match("/^[^\s]/i", $field_desc['null'])) $sql .= " ".$field_desc['null']; - if (preg_match("/^[^\s]/i", $field_desc['default'])) - if (preg_match("/null/i", $field_desc['default'])) + if (preg_match("/^[^\s]/i", $field_desc['default'])) { + if (preg_match("/null/i", $field_desc['default'])) { $sql .= " default ".$field_desc['default']; - else - $sql .= " default '".$field_desc['default']."'"; - if (preg_match("/^[^\s]/i", $field_desc['extra'])) - $sql .= " ".$field_desc['extra']; + } else { + $sql .= " default '".$field_desc['default']."'"; + } + } + if (preg_match("/^[^\s]/i", $field_desc['extra'])) { + $sql .= " ".$field_desc['extra']; + } $sql .= " ".$field_position; dol_syslog($sql, LOG_DEBUG); diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 29308ab7b77..af529e97fae 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -149,9 +149,9 @@ class DoliDBSqlite3 extends DoliDB { if ($type == 'auto') { - if (preg_match('/ALTER TABLE/i', $line)) $type='dml'; - elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml'; - elseif (preg_match('/DROP TABLE/i', $line)) $type='dml'; + if (preg_match('/ALTER TABLE/i', $line)) $type='dml'; + elseif (preg_match('/CREATE TABLE/i', $line)) $type='dml'; + elseif (preg_match('/DROP TABLE/i', $line)) $type='dml'; } if ($type == 'dml') diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 54c0f02abde..103e3df3c5b 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1081,7 +1081,7 @@ function price2numjs(amount) { global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) { -?> + ?> // Defined properties for JNotify $(document).ready(function() { if (typeof $.jnotify == 'function') diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 21bff7bc8b3..e31f9b6d7d7 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -670,7 +670,45 @@ function security_prepare_head() return $head; } +/** + * Prepare array with list of tabs + * @param object $object descriptor class + * @return array Array of tabs to show + */ +function modulehelp_prepare_head($object) +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + // FIX for compatibity habitual tabs + $object->id = $object->numero; + + $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$object->id.'&mode=desc'; + $head[$h][1] = $langs->trans("Description"); + $head[$h][2] = 'desc'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$object->id.'&mode=feature'; + $head[$h][1] = $langs->trans("TechnicalServicesProvided"); + $head[$h][2] = 'feature'; + $h++; + + if ($object->isCoreOrExternalModule() == 'external') + { + $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$object->id.'&mode=changelog'; + $head[$h][1] = $langs->trans("ChangeLog"); + $head[$h][2] = 'changelog'; + $h++; + } + + complete_head_from_modules($conf, $langs, null, $head, $h, 'modulehelp_admin'); + + complete_head_from_modules($conf, $langs, null, $head, $h, 'modulehelp_admin', 'remove'); + + + return $head; +} /** * Prepare array with list of tabs * diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index f331a0e5320..af859ccca7f 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -237,6 +237,7 @@ function show_array_actions_to_do($max = 5) { $num = $db->num_rows($resql); + print '
    '; print ''; print ''; print ''; @@ -292,7 +293,7 @@ function show_array_actions_to_do($max = 5) $i++; } - print "
    '.$langs->trans("LastActionsToDo", $max).''.$langs->trans("FullList").'

    "; + print "

    "; $db->free($resql); } @@ -334,6 +335,7 @@ function show_array_last_actions_done($max = 5) { $num = $db->num_rows($resql); + print '
    '; print ''; print ''; print ''; @@ -380,7 +382,7 @@ function show_array_last_actions_done($max = 5) } // TODO Ajouter rappel pour "il y a des contrats a mettre en service" // TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration" - print "
    '.$langs->trans("LastDoneTasks", $max).''.$langs->trans("FullList").'

    "; + print "

    "; $db->free($resql); } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 9ab911ca1de..8991e1ad23b 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -31,7 +31,7 @@ * * @param string $selected Preselected value * @param string $htmlname HTML name of input field - * @param string $url Url for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list) + * @param string $url Ajax Url to call for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list) * @param string $urloption More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value diff --git a/htdocs/core/lib/expedition.lib.php b/htdocs/core/lib/expedition.lib.php index 5625bc9c012..7c329940b2d 100644 --- a/htdocs/core/lib/expedition.lib.php +++ b/htdocs/core/lib/expedition.lib.php @@ -94,18 +94,18 @@ function expedition_admin_prepare_head() if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { - $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFields"); - $head[$h][2] = 'attributes_shipment'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes_shipment'; + $h++; } if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { - $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; - $head[$h][1] = $langs->trans("ExtraFieldsLines"); - $head[$h][2] = 'attributeslines_shipment'; - $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFieldsLines"); + $head[$h][2] = 'attributeslines_shipment'; + $h++; } if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index f1fd6ed220f..07d51105ca8 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1848,10 +1848,15 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = '' if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext; $count = $image->getNumberImages(); - if (! dol_is_file($fileoutput) || is_writeable($fileoutput)) { - $ret = $image->writeImages($fileoutput, true); + try { + $ret = $image->writeImages($fileoutput, true); + } + catch(Exception $e) + { + dol_syslog($e->getMessage(), LOG_WARNING); + } } else { diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index a05a62f5957..30eba9867b8 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -832,12 +832,12 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if (strstr($mask, 'user_extra_')) { - $start = "{user_extra_"; - $end = "\}"; - $extra= get_string_between($mask, "user_extra_", "}"); - if(!empty($user->array_options['options_'.$extra])){ - $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); - } + $start = "{user_extra_"; + $end = "\}"; + $extra= get_string_between($mask, "user_extra_", "}"); + if (!empty($user->array_options['options_'.$extra])) { + $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); + } } $maskwithonlyymcode=$mask; $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i', $maskcounter, $maskwithonlyymcode); @@ -1645,7 +1645,7 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) //irtoscan.=($dirtoscan?',':'').preg_replace('/[\r\n]+/',',',trim($conf->global->$const)); $dirtoscan= preg_replace('/[\r\n]+/', ',', trim($conf->global->$const)); - $listoffiles=array(); + $listoffiles=array(); // Now we add models found in directories scanned $listofdir=explode(',', $dirtoscan); @@ -1656,8 +1656,8 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) if (! $tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { - // all type of template is allowed - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); + // all type of template is allowed + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '', '', 'name', SORT_ASC, 0); if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); } } diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 0b06d21c95d..004f355a27a 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -137,11 +137,11 @@ function invoice_admin_prepare_head() $head[$h][2] = 'payment'; $h++; - if($conf->global->INVOICE_USE_SITUATION){ - $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; - $head[$h][1] = $langs->trans("InvoiceSituation"); - $head[$h][2] = 'situation'; - $h++; + if ($conf->global->INVOICE_USE_SITUATION) { + $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; + $head[$h][1] = $langs->trans("InvoiceSituation"); + $head[$h][2] = 'situation'; + $h++; } // Show more tabs from modules diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 8c97bbb348f..3ce9d871b7f 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -353,24 +353,24 @@ function utf82utf16($utf8) { // oh please oh please oh please oh please oh please if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); } switch(strlen($utf8)) { case 1: - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return $utf8; + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; case 2: - // return a UTF-16 character from a 2-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1}))); case 3: - // return a UTF-16 character from a 3-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2}))); } // ignoring UTF-32 for now, sorry diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 609201dd0c3..918b5ebb6a3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1417,8 +1417,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, //print '>'.$outputlangs->charset_output.','.$period; if(!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)){ $libelleproduitservice.= ''."__N__ ".$period.''; - }else{ - $libelleproduitservice.="__N__".$period; + } else { + $libelleproduitservice.="__N__".$period; } //print $libelleproduitservice; } @@ -1705,8 +1705,8 @@ function pdf_getlineqty($object, $i, $outputlangs, $hidedetails = 0) } if (empty($reshook)) { - if ($object->lines[$i]->special_code == 3) return ''; - if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; + if ($object->lines[$i]->special_code == 3) return ''; + if (empty($hidedetails) || $hidedetails > 1) $result.=$object->lines[$i]->qty; } return $result; } @@ -2108,7 +2108,7 @@ function pdf_getLinkedObjects($object, $outputlangs) { if ($objecttype == 'facture') { - // For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width. + // For invoice, we don't want to have a reference line on document. Image we are using recuring invoice, we will have a line longer than document width. } elseif ($objecttype == 'propal' || $objecttype == 'supplier_proposal') { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 9ba505e9eae..f4efd0c0ee9 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -204,15 +204,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $localtaxes = array(0,0,0); $apply_tax = false; switch($localtax1_type) { - case '2': // localtax on product or service - $apply_tax = true; - break; - case '4': // localtax on product - if ($type == 0) $apply_tax = true; - break; - case '6': // localtax on service - if ($type == 1) $apply_tax = true; - break; + case '2': // localtax on product or service + $apply_tax = true; + break; + case '4': // localtax on product + if ($type == 0) $apply_tax = true; + break; + case '6': // localtax on service + if ($type == 1) $apply_tax = true; + break; } if ($uselocaltax1_rate && $apply_tax) { @@ -299,15 +299,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $apply_tax = false; switch($localtax1_type) { - case '1': // localtax on product or service - $apply_tax = true; - break; - case '3': // localtax on product - if ($type == 0) $apply_tax = true; - break; - case '5': // localtax on service - if ($type == 1) $apply_tax = true; - break; + case '1': // localtax on product or service + $apply_tax = true; + break; + case '3': // localtax on product + if ($type == 0) $apply_tax = true; + break; + case '5': // localtax on service + if ($type == 1) $apply_tax = true; + break; } if ($uselocaltax1_rate && $apply_tax) { $result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 106ce8336a8..0c80b05c9cd 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1371,7 +1371,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ { for ($i = 0 ; $i < $numlines ; $i++) { - if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; + if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i]; } } @@ -1848,7 +1848,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $resql = $db->query($sql2); if ($resql) { - $total_task = 0; + $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 0b72fe4645a..a4b96a6b650 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -312,17 +312,26 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f foreach($feature2 as $subfeature) { if (empty($user->rights->$feature->$subfeature->creer) - && empty($user->rights->$feature->$subfeature->write) - && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } - else { $createok=1; break; } // Break to bypass second test if the first is ok + && empty($user->rights->$feature->$subfeature->write) + && empty($user->rights->$feature->$subfeature->create)) { + $createok=0; + $nbko++; + } else { + $createok=1; + // Break to bypass second test if the first is ok + break; + } } } elseif (! empty($feature)) // This is for permissions on 2 levels ('creer' or 'write') { //print '
    feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; if (empty($user->rights->$feature->creer) - && empty($user->rights->$feature->write) - && empty($user->rights->$feature->create)) { $createok=0; $nbko++; } + && empty($user->rights->$feature->write) + && empty($user->rights->$feature->create)) { + $createok=0; + $nbko++; + } } } diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 5ff41f97495..63e9a2fc9ff 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -234,7 +234,7 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ } if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) { - print '' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ''; + print '' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ''; } print '
    '; } @@ -690,10 +690,10 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out.=$actionstatic->getNomUrl(1, -1).' '; } -// if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id) -// { -// $out.=''.$langs->trans('Show').''; -// } + //if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id) + //{ + // $out.=''.$langs->trans('Show').''; + //} if ($user->rights->agenda->allactions->create || @@ -723,9 +723,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no $out.="\n"; // Ref - - $out.='

    '; - + $out.='

    '; // Author of event $out.=''; @@ -739,11 +737,9 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no } $out.=''; - // Title $out .= ' '; - if($actionstatic->code == 'TICKET_MSG') { $out .= $langs->trans('TicketNewMessage'); } diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 57a26523c12..63a4c6d01e6 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -156,41 +156,41 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) // ldap2dolibarr synchronisation if ($login && ! empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') // ldap2dolibarr synchronisation { - dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr"); + dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr"); - // On charge les attributs du user ldap - if ($ldapdebug) print "DEBUG: login ldap = ".$login."
    \n"; - $resultFetchLdapUser = $ldap->fetch($login, $userSearchFilter); + // On charge les attributs du user ldap + if ($ldapdebug) print "DEBUG: login ldap = ".$login."
    \n"; + $resultFetchLdapUser = $ldap->fetch($login, $userSearchFilter); - if ($ldapdebug) print "DEBUG: UACF = ".join(',', $ldap->uacf)."
    \n"; - if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."
    \n"; - if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."
    \n"; + if ($ldapdebug) print "DEBUG: UACF = ".join(',', $ldap->uacf)."
    \n"; + if ($ldapdebug) print "DEBUG: pwdLastSet = ".dol_print_date($ldap->pwdlastset, 'day')."
    \n"; + if ($ldapdebug) print "DEBUG: badPasswordTime = ".dol_print_date($ldap->badpwdtime, 'day')."
    \n"; - // On recherche le user dolibarr en fonction de son SID ldap (only for Active Directory) - $sid = null; - if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") + // On recherche le user dolibarr en fonction de son SID ldap (only for Active Directory) + $sid = null; + if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") + { + $sid = $ldap->getObjectSid($login); + if ($ldapdebug) print "DEBUG: sid = ".$sid."
    \n"; + } + + $usertmp=new User($db); + $resultFetchUser=$usertmp->fetch('', $login, $sid); + if ($resultFetchUser > 0) + { + dol_syslog("functions_ldap::check_user_password_ldap Sync user found user id=".$usertmp->id); + // On verifie si le login a change et on met a jour les attributs dolibarr + + if ($usertmp->login != $ldap->login && $ldap->login) { - $sid = $ldap->getObjectSid($login); - if ($ldapdebug) print "DEBUG: sid = ".$sid."
    \n"; + $usertmp->login = $ldap->login; + $usertmp->update($usertmp); + // TODO Que faire si update echoue car on update avec un login deja existant. } - $usertmp=new User($db); - $resultFetchUser=$usertmp->fetch('', $login, $sid); - if ($resultFetchUser > 0) - { - dol_syslog("functions_ldap::check_user_password_ldap Sync user found user id=".$usertmp->id); - // On verifie si le login a change et on met a jour les attributs dolibarr - - if ($usertmp->login != $ldap->login && $ldap->login) - { - $usertmp->login = $ldap->login; - $usertmp->update($usertmp); - // TODO Que faire si update echoue car on update avec un login deja existant. - } - - //$resultUpdate = $usertmp->update_ldap2dolibarr($ldap); - } - unset($usertmp); + //$resultUpdate = $usertmp->update_ldap2dolibarr($ldap); + } + unset($usertmp); } if (! empty($conf->multicompany->enabled)) // We must check entity (even if sync is not active) @@ -240,7 +240,6 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) // Load translation files required by the page $langs->loadLangs(array('main', 'other', 'errors')); -; $_SESSION["dol_loginmesg"]=($ldap->error?$ldap->error:$langs->trans("ErrorBadLoginPassword")); } diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 089194aec2a..b5913bbde20 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -79,7 +79,7 @@ class MenuManager $_SESSION["leftmenuopened"]=""; } else - { + { // On va le chercher en session si non defini par le lien $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 11d6ac9dd34..f3f0a5795c5 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -307,10 +307,12 @@ class MenuManager print $val2['titre']; if ($relurl2) { - if ($val2['enabled']) // Allowed - print ''; - else - print ''; + if ($val2['enabled']) { + // Allowed + print ''; + } else { + print ''; + } } print ''."\n"; } @@ -448,7 +450,7 @@ class MenuManager unset($this->menu->liste); } } -/* + /* if ($mode == 'jmobile') { foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' @@ -506,7 +508,7 @@ class MenuManager break; // Only first menu entry (so home) } } -*/ + */ unset($this->menu); return $res; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 6be9aa859c3..b8fc623709d 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -49,7 +49,10 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto; // Automatic Numbering + /** + * @var int Automatic numbering + */ + public $code_auto; public $searchcode; // Search string diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php new file mode 100644 index 00000000000..8885348bb16 --- /dev/null +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -0,0 +1,518 @@ + + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php + * \ingroup bom + * \brief File of class to build ODT documents for BOMs + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/bom/modules_bom.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_bom_odt extends ModelePDFBOMs +{ + /** + * Issuer + * @var Societe + */ + public $emetteur; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * @var string Dolibarr version of the loaded document + */ + public $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'BOM_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Page size for A4 format + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf,$langs; + + // Load translation files required by the page + $langs->loadLangs(array("errors","companies")); + + $form = new Form($this->db); + + $texte = $this->description.".
    \n"; + $texte.= '
    '; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
    '; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->BOM_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else + { + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte.= '
    '; + $texte.= ''; + $texte.= '
    '; + $texte.= ''; + $texte.= '
    '; + + // Scan directories + $nbofiles=count($listoffiles); + if (! empty($conf->global->BOM_ADDON_PDF_ODT_PATH)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte.=count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte.=''; + } + + if ($nbofiles) + { + $texte.='
    '; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
    '; + $texte.= '
    '; + + return $texte; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build a document on disk using the generic odt module. + * + * @param Commande $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user,$langs,$conf,$mysoc,$hookmanager; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); + + if ($conf->commande->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Commande($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db, $object->error); + return -1; + } + } + + $dir = $conf->commande->multidir_output[$object->entity]; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp=$objectref.'_'.$newfiletmp; + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; + + dol_mkdir($conf->bom->dir_temp); + + + // If CUSTOMER contact defined on order, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + $contactobject=null; + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } + + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='ORDER_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->commande->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object, $outputlangs); + $array_user=$this->get_substitutionarray_user($user, $outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + + $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + // Replace tags of lines + try + { + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + catch(SegmentException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); + } + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + + // Call the beforeODTSave hook + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + } catch (Exception $e) { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + return -1; + } +} diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index eed79c037fd..4a139b98379 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -23,7 +23,7 @@ /** * \file htdocs/core/modules/bom/mod_bom_advanced.php * \ingroup bom - * \brief File containing class for numbering model of bom advanced + * \brief File containing class for numbering model of BOMs advanced */ require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index eefbc7570c0..77c0856d3f6 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/modules/bom/mod_bom_standard.php * \ingroup bom - * \brief File of class to manage customer order numbering rules standard + * \brief File of class to manage BOMs numbering rules standard */ require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; diff --git a/htdocs/core/modules/bom/modules_bom.php b/htdocs/core/modules/bom/modules_bom.php index 9f871d0b578..f8f29fec2e6 100644 --- a/htdocs/core/modules/bom/modules_bom.php +++ b/htdocs/core/modules/bom/modules_bom.php @@ -52,7 +52,7 @@ abstract class ModelePDFBoms extends CommonDocGenerator // phpcs:enable global $conf; - $type = 'order'; + $type = 'bom'; $list = array(); include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index f66fc13770c..c90eca21ae4 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -486,7 +486,7 @@ class doc_generic_order_odt extends ModelePDFCommandes } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index c101f73fca0..5d69840644e 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -912,66 +912,64 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // VAT foreach($this->tva as $tvakey => $tvaval) @@ -1001,67 +999,67 @@ class pdf_einstein extends ModelePDFCommandes //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // Total TTC diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index d3f7f3016a0..30b8604a298 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1,13 +1,13 @@ - * Copyright (C) 2005-2012 Regis Houssin +/* Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1099,66 +1099,63 @@ class pdf_eratosthene extends ModelePDFCommandes //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // VAT foreach($this->tva as $tvakey => $tvaval) @@ -1188,67 +1185,67 @@ class pdf_eratosthene extends ModelePDFCommandes //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // Total TTC diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index a6d9514d7a7..f1324605874 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -342,7 +342,7 @@ class doc_generic_contract_odt extends ModelePDFContract // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->contrat->dir_temp, @@ -470,7 +470,7 @@ class doc_generic_contract_odt extends ModelePDFContract } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); return -1; diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 7bb13f79af1..8e723cba8df 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -53,6 +53,9 @@ class mod_contract_magre extends ModelNumRefContracts */ public $name='Magre'; + /** + * @var int Automatic numbering + */ public $code_auto=1; /** diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index 405781a48ae..6a198fdb309 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -58,7 +58,10 @@ class mod_contract_olive extends ModelNumRefContracts */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto = 0; // Numerotation automatique + /** + * @var int Automatic numbering + */ + public $code_auto = 0; /** diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 9477e79b96f..f8f287d3dd6 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -53,6 +53,9 @@ class mod_contract_serpis extends ModelNumRefContracts */ public $name='Serpis'; + /** + * @var int Automatic numbering + */ public $code_auto=1; diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 311f1d8f813..bcda35459f6 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -322,82 +322,80 @@ class html_cerfafr extends ModeleDon } elseif ($dix[$i]==2) { if ($unite[$i]==1) { - $secon[$i]='vingt et'; - $prim[$i]=$chif[$unite[$i]]; - } - else { - $secon[$i]='vingt'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='vingt et'; + $prim[$i]=$chif[$unite[$i]]; + } else { + $secon[$i]='vingt'; + $prim[$i]=$chif[$unite[$i]]; } } elseif ($dix[$i]==3) { if ($unite[$i]==1) { - $secon[$i]='trente et'; - $prim[$i]=$chif[$unite[$i]]; - } - else { - $secon[$i]='trente'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='trente et'; + $prim[$i]=$chif[$unite[$i]]; + } else { + $secon[$i]='trente'; + $prim[$i]=$chif[$unite[$i]]; } } elseif ($dix[$i]==4) { if ($unite[$i]==1) { - $secon[$i]='quarante et'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='quarante et'; + $prim[$i]=$chif[$unite[$i]]; } else { - $secon[$i]='quarante'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='quarante'; + $prim[$i]=$chif[$unite[$i]]; } } elseif ($dix[$i]==5) { if ($unite[$i]==1) { - $secon[$i]='cinquante et'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='cinquante et'; + $prim[$i]=$chif[$unite[$i]]; } else { - $secon[$i]='cinquante'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='cinquante'; + $prim[$i]=$chif[$unite[$i]]; } } elseif ($dix[$i]==6) { if ($unite[$i]==1) { - $secon[$i]='soixante et'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='soixante et'; + $prim[$i]=$chif[$unite[$i]]; } else { - $secon[$i]='soixante'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='soixante'; + $prim[$i]=$chif[$unite[$i]]; } } elseif ($dix[$i]==7) { if ($unite[$i]==1) { - $secon[$i]='soixante et'; - $prim[$i]=$chif[$unite[$i]+10]; + $secon[$i]='soixante et'; + $prim[$i]=$chif[$unite[$i]+10]; } else { - $secon[$i]='soixante'; - $prim[$i]=$chif[$unite[$i]+10]; + $secon[$i]='soixante'; + $prim[$i]=$chif[$unite[$i]+10]; } } elseif ($dix[$i]==8) { if ($unite[$i]==1) { - $secon[$i]='quatre-vingts et'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='quatre-vingts et'; + $prim[$i]=$chif[$unite[$i]]; } else { - $secon[$i]='quatre-vingt'; - $prim[$i]=$chif[$unite[$i]]; + $secon[$i]='quatre-vingt'; + $prim[$i]=$chif[$unite[$i]]; } } elseif ($dix[$i]==9) { if ($unite[$i]==1) { - $secon[$i]='quatre-vingts et'; - $prim[$i]=$chif[$unite[$i]+10]; + $secon[$i]='quatre-vingts et'; + $prim[$i]=$chif[$unite[$i]+10]; } else { - $secon[$i]='quatre-vingts'; - $prim[$i]=$chif[$unite[$i]+10]; + $secon[$i]='quatre-vingts'; + $prim[$i]=$chif[$unite[$i]+10]; } } if($cent[$i]==1) $trio[$i]='cent'; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 797049e8f57..7dbd3002e33 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -562,7 +562,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 7757e3c9b56..25b691aaa70 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -218,26 +218,25 @@ class pdf_rouget extends ModelePdfExpedition $realpath=''; - foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { + // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + if ($obj['photo_vignette']) { - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo - { - if ($obj['photo_vignette']) - { - $filename= $obj['photo_vignette']; - } - else - { - $filename=$obj['photo']; - } - } - else - { - $filename=$obj['photo']; - } + $filename= $obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + } + else + { + $filename=$obj['photo']; + } - $realpath = $dir.$filename; - break; + $realpath = $dir.$filename; + break; } if ($realpath) $realpatharray[$i]=$realpath; @@ -541,8 +540,8 @@ class pdf_rouget extends ModelePdfExpedition if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { - $pdf->SetXY($this->posxqtyordered, $curY); - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); + $pdf->SetXY($this->posxqtyordered, $curY); + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); } if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index 412446166d7..f703561ea03 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -139,19 +139,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport $result = $db->query($sql); - if($db->num_rows($result) > 0): - $objp = $db->fetch_object($result); - $newref = $objp->max; - $newref++; - while(strlen($newref) < $num_car): - $newref = "0".$newref; - endwhile; - else: - $newref = 1; - while(strlen($newref) < $num_car): - $newref = "0".$newref; - endwhile; - endif; + if ($db->num_rows($result) > 0) { + $objp = $db->fetch_object($result); + $newref = $objp->max; + $newref++; + while (strlen($newref) < $num_car) { + $newref = "0".$newref; + } + } else { + $newref = 1; + while (strlen($newref) < $num_car) { + $newref = "0".$newref; + } + } $ref_number_int = ($newref+1)-1; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 008b9a191c2..bb39f88c45d 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -344,7 +344,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->facture->dir_temp, diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 4320c63f58b..2b198c35336 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1177,69 +1177,69 @@ class pdf_crabe extends ModelePDFFactures //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} @@ -1271,43 +1271,12 @@ class pdf_crabe extends ModelePDFFactures //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach ($this->localtax1 as $localtax_type => $localtax_rate) { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) - { - if ($tvakey != 0) // On affiche pas taux 0 - { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); - } - } - } - //} - //Local tax 2 after VAT - //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') - //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) - { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; @@ -1320,15 +1289,45 @@ class pdf_crabe extends ModelePDFFactures $tvakey=str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } + //} + //Local tax 2 after VAT + //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') + //{ + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) + { + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) + { + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + } + } //} // Revenue stamp diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index ae8b33793d2..07ed5f5783c 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -371,10 +371,10 @@ class pdf_sponge extends ModelePDFFactures // Does we have at least one line with discount $this->atleastonediscount foreach ($object->lines as $line) { - if ($line->remise_percent){ + if ($line->remise_percent) { $this->atleastonediscount = true; break; - } + } } @@ -769,65 +769,62 @@ class pdf_sponge extends ModelePDFFactures } // retrieve global local tax - if ($localtax1_type && $localtax1ligne != 0) - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; - if ($localtax2_type && $localtax2ligne != 0) - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + if ($localtax1_type && $localtax1ligne != 0) { + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + } + if ($localtax2_type && $localtax2ligne != 0) { + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + } - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; - $this->tva[$vatrate] += $tvaligne; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + $this->tva[$vatrate] += $tvaligne; - $nexY = max($nexY, $posYAfterImage); + $nexY = max($nexY, $posYAfterImage); - // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) - { - $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); - //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); - $pdf->SetLineStyle(array('dash'=>0)); - } + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } - $nexY+=2; // Add space between lines + $nexY+=2; // Add space between lines - // Detect if some page were added automatically and output _tableau for past pages - while ($pagenb < $pageposafter) - { - $pdf->setPage($pagenb); - if ($pagenb == $pageposbeforeprintlines) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); - } - $this->_pagefoot($pdf, $object, $outputlangs, 1); - $pagenb++; - $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - } + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) { + $pdf->setPage($pagenb); + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf, $object, $outputlangs, 1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) - { - if ($pagenb == $pageposafter) - { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); - } - $this->_pagefoot($pdf, $object, $outputlangs, 1); - // New page - $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) { + if ($pagenb == $pageposafter) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf, $object, $outputlangs, 1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } } // Show square @@ -1266,14 +1263,11 @@ class pdf_sponge extends ModelePDFFactures $deja_paye = 0; $i = 1; - if(!empty($TPreviousIncoice)){ + if (!empty($TPreviousIncoice)) { $pdf->setY($tab2_top); $posy = $pdf->GetY(); - - - - foreach ($TPreviousIncoice as &$fac){ + foreach ($TPreviousIncoice as &$fac) { if($posy > $this->page_hauteur - 4 ) { $this->_pagefoot($pdf, $object, $outputlangs, 1); $pdf->addPage(); @@ -1290,8 +1284,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col2x, $posy); $facSign = ''; - if($i>1){ - $facSign = $fac->total_ht>=0?'+':''; + if ($i>1) { + $facSign = $fac->total_ht>=0?'+':''; } $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs); @@ -1312,11 +1306,11 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetXY($col2x, $posy); $facSign = ''; - if($i>1){ + if ($i>1) { $facSign = $object->total_ht>=0?'+':''; // management of a particular customer case } - if($fac->type === facture::TYPE_CREDIT_NOTE){ + if ($fac->type === facture::TYPE_CREDIT_NOTE) { $facSign = '-'; // les avoirs } @@ -1375,7 +1369,7 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount"), 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + 0); + $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1); $index++; @@ -1410,70 +1404,67 @@ class pdf_sponge extends ModelePDFFactures //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1', '3', '5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } - + } //} // VAT @@ -1527,68 +1518,68 @@ class pdf_sponge extends ModelePDFFactures //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + // retrieve global local tax + if ($tvakey != 0) // On affiche pas taux 0 { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } // Revenue stamp diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index ac59960cf59..ff7bff51230 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -502,7 +502,7 @@ class pdf_soleil extends ModelePDFFicheinter $default_font_size = pdf_getPDFFontSize($outputlangs); -/* + /* $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); @@ -526,7 +526,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. -*/ + */ // Output Rect $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0); // Rect takes a length in 3rd parameter and 4th parameter diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 7defb2f6dad..dee02685bf6 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -53,6 +53,9 @@ class mod_holiday_immaculate extends ModelNumRefHolidays */ public $name='Immaculate'; + /** + * @var int Automatic numbering + */ public $code_auto=1; /** diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 1d290ce0909..1cd1274869f 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -54,6 +54,9 @@ class mod_holiday_madonna extends ModelNumRefHolidays */ public $name='Madonna'; + /** + * @var int Automatic numbering + */ public $code_auto=1; diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index cb3ae176026..08ac267445d 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -217,9 +217,9 @@ class ImportCsv extends ModeleImports * @return int <0 if KO, >=0 if OK */ public function import_get_nb_of_lines($file) - { + { // phpcs:enable - return dol_count_nb_of_line($file); + return dol_count_nb_of_line($file); } diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 670b831c25f..25ffcb717fd 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -255,9 +255,11 @@ class mailing_fraise extends MailingTargets $sql.= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")"; // Filter on status - if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1"; - if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)"; - if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)"; + if (isset($_POST["filter"]) && $_POST["filter"] == '-1') { + $sql.= " AND a.statut=-1"; + } + if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)"; + if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)"; if (isset($_POST["filter"]) && $_POST["filter"] == '0') $sql.= " AND a.statut=0"; // Filter on date if ($dateendsubscriptionafter > 0) $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'"; diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 00db6eb89ea..68cb49e10d9 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -288,29 +288,28 @@ class mailing_thirdparties extends MailingTargets } $s.=' '; - $s.= $langs->trans('ProspectCustomer'); - $s.=': '; + $s.= ''; + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { + $s.= ''; + } + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) { + $s.= ''; + } + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $s.= ''; + } + $s.= ''; - $s.=' '; + $s.= ' '; - $s.=$langs->trans("Status"); - $s.=': '; + $s.= $langs->trans("Status"); + $s.= ': '; return $s; } diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index e333103fc8d..720721ac156 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -189,9 +189,7 @@ class modBom extends DolibarrModules // Boxes/Widgets // Add here list of php file(s) stored in bom/core/boxes that contains class to show a widget. $this->boxes = array( - //0=>array('file'=>'bomwidget1.php@bom','note'=>'Widget provided by Bom','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'bomwidget2.php@bom','note'=>'Widget provided by Bom'), - //2=>array('file'=>'bomwidget3.php@bom','note'=>'Widget provided by Bom') + 0=>array('file'=>'box_boms.php','note'=>'','enabledbydefaulton'=>'Home') ); diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index dbea2fe8d8a..fc8557497b8 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -35,11 +35,11 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modComptabilite extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ public function __construct($db) { global $conf; @@ -72,11 +72,12 @@ class modComptabilite extends DolibarrModules $this->const = array(); // Data directories to create when module is enabled - $this->dirs = array("/comptabilite/temp", - "/comptabilite/rapport", - "/comptabilite/export", - "/comptabilite/bordereau" - ); + $this->dirs = array( + "/comptabilite/temp", + "/comptabilite/rapport", + "/comptabilite/export", + "/comptabilite/bordereau" + ); // Boxes $this->boxes = array(); diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index bd11774eb21..1aefb52ea1c 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -32,10 +32,10 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modECM extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ public function __construct($db) { diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 152f2101893..68f4a3d5fba 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -298,11 +298,10 @@ class modExpedition extends DolibarrModules $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) - { - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; + if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; diff --git a/htdocs/mrp/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php similarity index 98% rename from htdocs/mrp/core/modules/modMrp.class.php rename to htdocs/core/modules/modMrp.class.php index 7e57f70c6c8..53f778d063f 100644 --- a/htdocs/mrp/core/modules/modMrp.class.php +++ b/htdocs/core/modules/modMrp.class.php @@ -206,12 +206,7 @@ class modMrp extends DolibarrModules // Boxes/Widgets // Add here list of php file(s) stored in mrp/core/boxes that contains a class to show a widget. $this->boxes = array( - // 0 => array( - // 'file' => 'mrpwidget1.php@mrp', - // 'note' => 'Widget provided by Mrp', - // 'enabledbydefaulton' => 'Home', - // ), - // ... + 0 => array('file' => 'box_mos.php', 'note' => '', 'enabledbydefaulton' => 'Home') ); // Cronjobs (List of cron jobs entries to add when module is enabled) diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 06c8f51f76b..63146e87318 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -223,11 +223,10 @@ class modReception extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch_extrafields as extra2 ON ed.rowid = extra2.fk_object'; $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; - if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) - { - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; + if ($idcontacts && ! empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) { + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid'; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('reception').')'; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index a225fe47005..5a2c5040e88 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -148,7 +148,7 @@ class modSociete extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; -/* $r++; + /*$r++; $this->rights[$r][0] = 241; $this->rights[$r][1] = 'Read thirdparties customers'; $this->rights[$r][2] = 'r'; @@ -163,7 +163,7 @@ class modSociete extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'thirdparty_supplier_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'read'; -*/ + */ $r++; $this->rights[$r][0] = 122; // id de la permission @@ -172,8 +172,8 @@ class modSociete extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; -/* $r++; - $this->rights[$r][0] = 251; + /* $r++; + $this->rights[$r][0] = 251; $this->rights[$r][1] = 'Create thirdparties customers'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; @@ -187,7 +187,7 @@ class modSociete extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'thirdparty_supplier_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'read'; -*/ + */ $r++; $this->rights[$r][0] = 125; // id de la permission diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index 7baf96f8d96..30d90b8a0c6 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -82,8 +82,8 @@ class modStripe extends DolibarrModules // New pages on tabs $this->tabs = array(); - // Boxes - $this->boxes = array(); // List of boxes + // List of boxes + $this->boxes = array(); $r=0; // Permissions @@ -92,8 +92,8 @@ class modStripe extends DolibarrModules // Main menu entries $r=0; - /* $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + /* $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'mainmenu'=>'billing', 'leftmenu'=>'customers_bills_payment_stripe', 'type'=>'left', // This is a Left menu entry diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 8b973c45624..8d7f16fcaf7 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -81,8 +81,6 @@ class modTicket extends DolibarrModules $this->module_parts = array( // Set this to 1 if module has its own trigger directory 'triggers' => 1, - // Set this to 1 if module has its own models directory - 'models' => 1, ); // Data directories to create when module is enabled. diff --git a/htdocs/core/modules/modVariants.class.php b/htdocs/core/modules/modVariants.class.php index 728107ea08f..2c9aad59425 100644 --- a/htdocs/core/modules/modVariants.class.php +++ b/htdocs/core/modules/modVariants.class.php @@ -92,7 +92,7 @@ class modVariants extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array( -// 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__' + // 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__' ); // Dictionaries diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index d4ffc02aaa8..52c25f2450e 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -185,17 +185,15 @@ class modWebsite extends DolibarrModules dol_mkdir($destroot); $docs=dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$'); - foreach($docs as $cursorfile) - { - $src=$srcroot.'/'.$cursorfile['name']; - $dest=$destroot.'/'.$cursorfile['name']; + foreach($docs as $cursorfile) { + $src=$srcroot.'/'.$cursorfile['name']; + $dest=$destroot.'/'.$cursorfile['name']; - $result=dol_copy($src, $dest, 0, 0); - if ($result < 0) - { - $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); - } + $result=dol_copy($src, $dest, 0, 0); + if ($result < 0) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + } } $sql = array(); diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php new file mode 100644 index 00000000000..6d85bfd3553 --- /dev/null +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -0,0 +1,518 @@ + + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php + * \ingroup mrp + * \brief File of class to build ODT documents for MOs + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/bom/modules_bom.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_mo_odt extends ModelePDFMOs +{ + /** + * Issuer + * @var Societe + */ + public $emetteur; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * @var string Dolibarr version of the loaded document + */ + public $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'MRP_MO_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Page size for A4 format + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf,$langs; + + // Load translation files required by the page + $langs->loadLangs(array("errors","companies")); + + $form = new Form($this->db); + + $texte = $this->description.".
    \n"; + $texte.= '
    '; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
    '; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MRP_MO_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else + { + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte.= '
    '; + $texte.= ''; + $texte.= '
    '; + $texte.= ''; + $texte.= '
    '; + + // Scan directories + $nbofiles=count($listoffiles); + if (! empty($conf->global->MRP_MO_ADDON_PDF_ODT_PATH)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte.=count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte.=''; + } + + if ($nbofiles) + { + $texte.='
    '; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
    '; + $texte.= '
    '; + + return $texte; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build a document on disk using the generic odt module. + * + * @param Commande $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user,$langs,$conf,$mysoc,$hookmanager; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); + + if ($conf->commande->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Commande($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db, $object->error); + return -1; + } + } + + $dir = $conf->commande->multidir_output[$object->entity]; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp=$objectref.'_'.$newfiletmp; + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; + + dol_mkdir($conf->bom->dir_temp); + + + // If CUSTOMER contact defined on order, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + $contactobject=null; + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } + + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='ORDER_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->commande->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object, $outputlangs); + $array_user=$this->get_substitutionarray_user($user, $outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + + $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + // Replace tags of lines + try + { + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + catch(SegmentException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); + } + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + + // Call the beforeODTSave hook + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + } catch (Exception $e) { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + return -1; + } +} diff --git a/htdocs/core/modules/mrp/mod_mrp_advanced.php b/htdocs/core/modules/mrp/mod_mrp_advanced.php new file mode 100644 index 00000000000..1c24b4010ba --- /dev/null +++ b/htdocs/core/modules/mrp/mod_mrp_advanced.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/mrp/mod_mrp_advanced.php + * \ingroup mrp + * \brief File containing class for numbering model of MOs advanced + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mrp.php'; + + +/** + * Class to manage customer Bom numbering rules advanced + */ +class mod_mrp_advanced extends ModeleNumRefMos +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error message + */ + public $error = ''; + + /** + * @var string name + */ + public $name='advanced'; + + + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; + + $langs->load("bills"); + + $form = new Form($db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
    \n"; + $texte.= '
    '; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Mo"), $langs->transnoentities("Mo")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
    '; + $texte.= '
    '; + + return $texte; + } + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $old_code_type=$mysoc->typent_code; + $mysoc->code_client='CCCCCCCCCC'; + $mysoc->typent_code='TTTTTTTTTT'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client=$old_code_client; + $mysoc->typent_code=$old_code_type; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask=$conf->global->MRP_ADVANCED_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $date = ($object->date_mo ? $object->date_mo : $object->date); + + $numFinal=get_next_value($db, $mask, 'mrp_mo', 'ref', '', null, $date); + + return $numFinal; + } +} diff --git a/htdocs/core/modules/mrp/mod_mrp_standard.php b/htdocs/core/modules/mrp/mod_mrp_standard.php new file mode 100644 index 00000000000..24f1b0a1f69 --- /dev/null +++ b/htdocs/core/modules/mrp/mod_mrp_standard.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/mrp/mod_mrp_standard.php + * \ingroup mrp + * \brief File of class to manage MO numbering rules standard + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/mrp/modules_mrp.php'; + +/** + * Class to manage customer order numbering rules standard + */ +class mod_mrp_standard extends ModeleNumRefMos +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + public $prefix='MO'; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string name + */ + public $name='standard'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + } + + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Checks if the numbers already in force in the data base do not + * cause conflicts that would prevent this numbering from working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=9; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_mrp_standard::getNextValue", LOG_DEBUG); + return -1; + } + + //$date=time(); + $date=$object->date_creation; + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max+1); + + dol_syslog("mod_mrp_standard::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/core/modules/mrp/modules_mrp.php b/htdocs/core/modules/mrp/modules_mrp.php new file mode 100644 index 00000000000..bd83fab70b7 --- /dev/null +++ b/htdocs/core/modules/mrp/modules_mrp.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/mrp/modules_mrp.php + * \ingroup bom + * \brief File that contains parent class for mos models + * and parent class for mos numbering models + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit + + +/** + * Parent class for mos models + */ +abstract class ModelePDFMos extends CommonDocGenerator +{ + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { + // phpcs:enable + global $conf; + + $type = 'mo'; + $list = array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + + return $list; + } +} + + + +/** + * Parent class to manage numbering of MOs + */ +abstract class ModeleNumRefMos +{ + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + /** + * Returns the default description of the numbering template + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoDescription"); + } + + /** + * Returns an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoExample"); + } + + /** + * Checks if the numbers already in force in the data base do not + * cause conflicts that would prevent this numbering from working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + return true; + } + + /** + * Returns next assigned value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Returns version of numbering module + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index ca0fbd50333..b5e857866b5 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -668,8 +668,7 @@ class pdf_standard extends ModelePDFProduct $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', - 'C'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C'); } } diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 18d91631d3c..523dc8bd7c4 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -60,7 +60,10 @@ class mod_codeproduct_elephant extends ModeleProductCode */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto; // Numerotation automatique + /** + * @var int Automatic numbering + */ + public $code_auto; public $searchcode; // String de recherche diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index 77e14200264..04a15c9b8a5 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -65,7 +65,10 @@ class mod_codeproduct_leopard extends ModeleProductCode */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto; // Numerotation automatique + /** + * @var int Automatic numbering + */ + public $code_auto; /** diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index a9593c6bbef..b26b46604ff 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -107,7 +107,7 @@ class pdf_beluga extends ModelePDFProjects $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - // Define position of columns + // Define position of columns if ($this->orientation == 'L' || $this->orientation == 'Landscape') { $this->posxref=$this->marge_gauche+1; $this->posxdate=$this->marge_gauche+105; diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 5ccac833601..d73ee22fbae 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -116,13 +116,13 @@ class mod_project_simple extends ModeleNumRefProjects } - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string Value if OK, 0 if KO - */ + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Project $project Object project + * @return string Value if OK, 0 if KO + */ public function getNextValue($objsoc, $project) { global $db,$conf; diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index edd90585089..342eaa26320 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -116,13 +116,13 @@ class mod_project_universal extends ModeleNumRefProjects return $numExample; } - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Project $project Object project - * @return string Value if OK, 0 if KO - */ + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Project $project Object project + * @return string Value if OK, 0 if KO + */ public function getNextValue($objsoc, $project) { global $db,$conf; diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 811d5b1c97b..65c7deb8edf 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -117,13 +117,13 @@ class mod_task_simple extends ModeleNumRefTask } - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Task $object Object Task - * @return string Value if OK, 0 if KO - */ + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Task $object Object Task + * @return string Value if OK, 0 if KO + */ public function getNextValue($objsoc, $object) { global $db,$conf; diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index cfba42090d1..018a10c80a2 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -116,13 +116,13 @@ class mod_task_universal extends ModeleNumRefTask return $numExample; } - /** - * Return next value - * - * @param Societe $objsoc Object third party - * @param Task $object Object task - * @return string Value if OK, 0 if KO - */ + /** + * Return next value + * + * @param Societe $objsoc Object third party + * @param Task $object Object task + * @return string Value if OK, 0 if KO + */ public function getNextValue($objsoc, $object) { global $db,$conf; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index c7303683d5c..5412343941c 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -515,7 +515,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d3693932f76..a79c17b47ca 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1088,68 +1088,68 @@ class pdf_azur extends ModelePDFPropales //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // VAT foreach($this->tva as $tvakey => $tvaval) @@ -1179,68 +1179,68 @@ class pdf_azur extends ModelePDFPropales //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + // retrieve global local tax + if ($tvakey != 0) // On affiche pas taux 0 { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // Total TTC diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 319f563ad28..7db062d3cbc 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1191,68 +1191,68 @@ class pdf_cyan extends ModelePDFPropales //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // VAT foreach($this->tva as $tvakey => $tvaval) @@ -1282,68 +1282,68 @@ class pdf_cyan extends ModelePDFPropales //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + // retrieve global local tax + if ($tvakey != 0) // On affiche pas taux 0 { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // Total TTC diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 9741a8fbfc5..0cd252924f3 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -497,7 +497,7 @@ class doc_generic_reception_odt extends ModelePdfReception } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e){ $this->error=$e->getMessage(); return -1; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index a84b86e908b..9dffb0eee69 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -142,26 +142,25 @@ class pdf_squille extends ModelePdfReception $realpath=''; - foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) + foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { + // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + if ($obj['photo_vignette']) { - if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo - { - if ($obj['photo_vignette']) - { - $filename= $obj['photo_vignette']; - } - else - { - $filename=$obj['photo']; - } - } - else - { - $filename=$obj['photo']; - } + $filename= $obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + } + else + { + $filename=$obj['photo']; + } - $realpath = $dir.$filename; - break; + $realpath = $dir.$filename; + break; } if ($realpath) $realpatharray[$i]=$realpath; @@ -461,14 +460,13 @@ class pdf_squille extends ModelePdfReception $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
    ':'').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
    ':'').$voltxt,'','C'); - if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) - { - $pdf->SetXY($this->posxqtyordered, $curY); - if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); - $totalOrdered+=$object->lines[$i]->qty_asked; - } - $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; + if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) { + $pdf->SetXY($this->posxqtyordered, $curY); + if($object->lines[$i]->fk_commandefourndet!=$fk_commandefourndet){ + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); + $totalOrdered+=$object->lines[$i]->qty_asked; + } + $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet; } $pdf->SetXY($this->posxqtytoship, $curY); diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index c389a6f77ed..2f78deefe68 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -197,14 +197,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc return -1; } - // Add odtgeneration hook - if (! is_object($hookmanager)) - { - include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); - } - $hookmanager->initHooks(array('odtgeneration')); - global $action; + // Add odtgeneration hook + if (! is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; if (! is_object($outputlangs)) $outputlangs=$langs; $sav_charset_output=$outputlangs->charset_output; @@ -408,17 +407,16 @@ class doc_generic_odt extends ModeleThirdPartyDoc } else { try { - $odfHandler->creator = $user->getFullName($outputlangs); - $odfHandler->title = $object->builddoc_filename; - $odfHandler->subject = $object->builddoc_filename; + $odfHandler->creator = $user->getFullName($outputlangs); + $odfHandler->title = $object->builddoc_filename; + $odfHandler->subject = $object->builddoc_filename; - if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) - { - $odfHandler->userdefined['dol_id'] = $object->id; - $odfHandler->userdefined['dol_element'] = $object->element; - } + if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) { + $odfHandler->userdefined['dol_id'] = $object->id; + $odfHandler->userdefined['dol_element'] = $object->element; + } - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e){ $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 430c50fb401..3a7d2c00613 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -53,7 +53,10 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto; // Numerotation automatique + /** + * @var int Automatic numbering + */ + public $code_auto; public $searchcode; // String de recherche diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 4ba5e490b07..80bb3013904 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -57,7 +57,10 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto; // Numerotation automatique + /** + * @var int Automatic numbering + */ + public $code_auto; /** diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 89774161635..6273f5e74ef 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -51,7 +51,10 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $code_auto; // Numerotation automatique + /** + * @var int Automatic numbering + */ + public $code_auto; public $prefixcustomer='CU'; diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index e19814c3cd4..0d6d2e3d420 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -495,7 +495,7 @@ class doc_generic_stock_odt extends ModelePDFStock } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index dd002a95766..89dbd9898bc 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -714,58 +714,56 @@ class pdf_canelle extends ModelePDFSuppliersInvoices { //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - //Local tax 1 - foreach($this->localtax1 as $tvakey => $tvaval) + //Local tax 1 + foreach ($this->localtax1 as $tvakey => $tvaval) { + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.= vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } + } //} //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - //Local tax 2 - foreach($this->localtax2 as $tvakey => $tvaval) + //Local tax 2 + foreach($this->localtax2 as $tvakey => $tvaval) { + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.= vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.= vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); } + } //} } diff --git a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php index b139f0330a1..bdb5e88bdb8 100644 --- a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php @@ -4,7 +4,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Philippe Grand - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2019 Tim Otte * * This program is free software; you can redistribute it and/or modify @@ -485,7 +485,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders } else { try { - $odfHandler->saveToDisk($file); + $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 5977764ca8a..f9b0d1b106c 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -674,7 +674,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $text=$this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } -/* + /* $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); @@ -734,7 +734,7 @@ class pdf_standard extends ModelePDFSuppliersPayments // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); -*/ + */ if ($showaddress) { // Sender properties diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index eb53b7b74be..95f7b0e45d0 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -365,7 +365,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->supplier_proposal->dir_temp, diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 7e23b6b8c91..ff8ab76c674 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -941,68 +941,68 @@ class pdf_aurore extends ModelePDFSupplierProposal //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('1','3','5'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('1','3','5'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey!=0) // On affiche pas taux 0 { - if ($tvakey!=0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // VAT foreach($this->tva as $tvakey => $tvaval) @@ -1032,68 +1032,68 @@ class pdf_aurore extends ModelePDFSupplierProposal //Local tax 1 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ - foreach($this->localtax1 as $localtax_type => $localtax_rate) + foreach($this->localtax1 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + if ($tvakey != 0) // On affiche pas taux 0 { - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} //Local tax 2 after VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on') //{ - foreach($this->localtax2 as $localtax_type => $localtax_rate) + foreach($this->localtax2 as $localtax_type => $localtax_rate) + { + if (in_array((string) $localtax_type, array('2','4','6'))) continue; + + foreach($localtax_rate as $tvakey => $tvaval) { - if (in_array((string) $localtax_type, array('2','4','6'))) continue; - - foreach($localtax_rate as $tvakey => $tvaval) + // retrieve global local tax + if ($tvakey != 0) // On affiche pas taux 0 { - // retrieve global local tax - if ($tvakey != 0) // On affiche pas taux 0 + //$this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + + $tvacompl=''; + if (preg_match('/\*/', $tvakey)) { - //$this->atleastoneratenotnull++; - - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - - $tvacompl=''; - if (preg_match('/\*/', $tvakey)) - { - $tvakey=str_replace('*', '', $tvakey); - $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; - } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - - $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - - $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); + $tvakey=str_replace('*', '', $tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + + $totalvat.=vatrate(abs($tvakey), 1).$tvacompl; + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); + + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); } } + } //} // Total TTC @@ -1240,7 +1240,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C'); } } @@ -1345,12 +1345,12 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } -/* PHFAVRE + /* PHFAVRE $posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R'); -*/ + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->date_livraison, "day", false, $outputlangs, true), '', 'R'); + */ if ($object->thirdparty->code_fournisseur) { diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index b59ca8c2b22..d1b1dfe1093 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -47,499 +47,492 @@ print ''; - print load_fiche_titre($langs->trans("AdvTgtTitle")); +print load_fiche_titre($langs->trans("AdvTgtTitle")); - print '
    ' . "\n"; - print '
    ' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; +print '
    ' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '
    ' . "\n"; - print '' . "\n"; - print '' . "\n"; +print '' . "\n"; - print '' . "\n"; +print '' . "\n"; +print '' . "\n"; - print '' . "\n"; +print '' . "\n"; - print '' . "\n"; +print '' . "\n"; - // Customer name - print '' . "\n"; +// Customer name +print '' . "\n"; - // Code Client - print '' . "\n"; +// Code Client +print '' . "\n"; - // Address Client - print '' . "\n"; +// Address Client +print '' . "\n"; - // Zip Client - print '' . "\n"; +// Zip Client +print '' . "\n"; - // City Client - print '' . "\n"; +// City Client +print '' . "\n"; - // Customer Country - print '' . "\n"; +// Customer Country +print '' . "\n"; - // State Customer - print '' . "\n"; +// State Customer +print '' . "\n"; - // Mother Company - print '' . "\n"; +// Mother Company +print '' . "\n"; - // Prospect/Customer - $selected = $array_query['cust_typecust']; - print '' . "\n"; +// Prospect/Customer +$selected = $array_query['cust_typecust']; +print '' . "\n"; - // Prospection status - print '' . "\n"; +// Prospection status +print '' . "\n"; - // Prospection comm status - print '' . "\n"; +// Prospection comm status +print '' . "\n"; - // Customer Type - print '' . "\n"; +// Customer Type +print '' . "\n"; - // Staff number - print '' . "\n"; +// Staff number +print '' . "\n"; - // Sales manager - print '' . "\n"; +// Sales manager +print '' . "\n"; - // Customer Default Langauge - if (! empty($conf->global->MAIN_MULTILANGS)) { - print '' . "\n"; +} + +if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . "\n"; +} + +// Standard Extrafield feature +if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $elementtype = Societe::$table_element; + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementtype); + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { + if ($key != 'ts_nameextra' && $key != 'ts_payeur') { + print '' . "\n"; - } + print '' . "\n"; - } - - // Standard Extrafield feature - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $elementtype = Societe::$table_element; - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementtype); - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { - if ($key != 'ts_nameextra' && $key != 'ts_payeur') { - print '' . "\n"; - } - } - } else { - $std_soc = new Societe($db); - $action_search = 'query'; - - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - $hookmanager->initHooks(array ('thirdpartycard')); - - $parameters=array(); - if (! empty($advTarget->id)) { - $parameters = array('array_query' => $advTarget->filtervalue); - } - // Other attributes - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); - print $hookmanager->resPrint; - } - - // State Contact - print '' . "\n"; - - // Civility - print ''; - - // contact name - print '' . "\n"; - print '' . "\n"; - - // Contact Country - print '' . "\n"; - - // Never send mass mailing - print '' . "\n"; - - // Contact Date Create - print '' . "\n"; - - // Contact update Create - print '' . "\n"; - - if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // Customer Categories - print '' . "\n"; - } - - // Standard Extrafield feature - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $elementype=Contact::$table_element; - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($db); - $extrafields->fetch_name_optionals_label($elementype); - foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) { - if($value == 'radio')$value = 'select'; - } - - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) - { - print '' . "\n"; } + } +} else { + $std_soc = new Societe($db); + $action_search = 'query'; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '
    ' . "\n"; +print '
    ' . "\n"; - print '' . "\n"; +print '' . "\n"; - print '
    ' . $langs->trans('AdvTgtNameTemplate') . ''; - if (! empty($template_id)) { - $default_template = $template_id; - } else { - $default_template = $advTarget->id; - } - print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element); - print ''; - print ''; - print ''; - print $langs->trans('AdvTgtOrCreateNewFilter'); - print ''; - print ''; - print '' . "\n"; - print '
    ' . $langs->trans('AdvTgtNameTemplate') . ''; +if (! empty($template_id)) { + $default_template = $template_id; +} else { + $default_template = $advTarget->id; +} +print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element); +print ''; +print ''; +print ''; +print $langs->trans('AdvTgtOrCreateNewFilter'); +print ''; +print ''; +print '' . "\n"; +print '
    ' . $langs->trans('AdvTgtTypeOfIncude') . ''; - print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); - print '
    ' . $langs->trans('AdvTgtTypeOfIncude') . ''; +print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); +print '
    ' . $langs->trans('ThirdPartyName'); - if (! empty($array_query['cust_name'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('ThirdPartyName'); +if (! empty($array_query['cust_name'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
    ' . $langs->trans('CustomerCode'); - if (! empty($array_query['cust_code'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('CustomerCode'); +if (! empty($array_query['cust_code'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
    ' . $langs->trans('Address'); - if (! empty($array_query['cust_adress'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('Address'); +if (! empty($array_query['cust_adress'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
    ' . $langs->trans('Zip'); - if (! empty($array_query['cust_zip'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('Zip'); +if (! empty($array_query['cust_zip'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
    ' . $langs->trans('Town'); - if (! empty($array_query['cust_city'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('Town'); +if (! empty($array_query['cust_city'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
    ' . $langs->trans("Country"); - if (count($array_query['cust_country']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); - print '' . "\n"; - print '
    ' . $langs->trans("Country"); +if (count($array_query['cust_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); +print '' . "\n"; +print '
    ' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); - if (count($array_query['cust_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray( - 'cust_status', array ( - '0' => $langs->trans('ActivityCeased'), - '1' => $langs->trans('InActivity') - ), - $array_query['cust_status'] - ); - print '' . "\n"; - print '
    ' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); +if (count($array_query['cust_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray( + 'cust_status', array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), + $array_query['cust_status'] +); +print '' . "\n"; +print '
    ' . $langs->trans("Maison mère"); - if (! empty($array_query['cust_mothercompany'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans("Maison mère"); +if (! empty($array_query['cust_mothercompany'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print ''; +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '
    ' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); - if (count($array_query['cust_typecust']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - $options_array = array ( - 2 => $langs->trans('Prospect'), - 3 => $langs->trans('ProspectCustomer'), - 1 => $langs->trans('Customer'), - 0 => $langs->trans('NorProspectNorCustomer') - ); - print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); - print '' . "\n"; - print '
    ' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); +if (count($array_query['cust_typecust']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +$options_array = array ( + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer'), + 1 => $langs->trans('Customer'), + 0 => $langs->trans('NorProspectNorCustomer') +); +print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); +print '' . "\n"; +print '
    ' . $langs->trans('ProspectLevel'); - if (count($array_query['cust_prospect_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); - print '' . "\n"; - print '
    ' . $langs->trans('ProspectLevel'); +if (count($array_query['cust_prospect_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); +print '' . "\n"; +print '
    ' . $langs->trans('StatusProsp'); - if (count($array_query['cust_comm_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); - print '' . "\n"; - print '
    ' . $langs->trans('StatusProsp'); +if (count($array_query['cust_comm_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); +print '' . "\n"; +print '
    ' . $langs->trans("ThirdPartyType"); - if (count($array_query['cust_typeent']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); - print '' . "\n"; - print '
    ' . $langs->trans("ThirdPartyType"); +if (count($array_query['cust_typeent']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); +print '' . "\n"; +print '
    ' . $langs->trans("Staff"); - if (count($array_query['cust_effectif_id']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); - print '' . "\n"; - print '
    ' . $langs->trans("Staff"); +if (count($array_query['cust_effectif_id']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); +print '' . "\n"; +print '
    ' . $langs->trans("SalesRepresentatives"); - if (count($array_query['cust_saleman']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); - print '' . "\n"; - print '
    ' . $langs->trans("SalesRepresentatives"); +if (count($array_query['cust_saleman']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); +print '' . "\n"; +print '
    ' . $langs->trans("DefaultLang"); - if (count($array_query['cust_language']) > 0) { +// Customer Default Langauge +if (! empty($conf->global->MAIN_MULTILANGS)) { + print '
    ' . $langs->trans("DefaultLang"); + if (count($array_query['cust_language']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); + print '' . "\n"; + print '
    ' . $langs->trans("CustomersCategoryShort"); + if (count($array_query['cust_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); + print '' . "\n"; + print '
    ' . $extrafields->attributes[$elementtype]['label'][$key]; + if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); } - print '' . "\n"; - print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); - print '' . "\n"; - print '
    '; + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { + print ''; + print '
    ' . $langs->trans("AdvTgtStartDt") . ''; + print $form->selectDate('', 'options_' . $key . '_st_dt'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->selectDate('', 'options_' . $key . '_end_dt'); + print '
    '; - if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // Customer Categories - print '
    ' . $langs->trans("CustomersCategoryShort"); - if (count($array_query['cust_categ']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); - print '' . "\n"; - print '
    ' . $extrafields->attributes[$elementtype]['label'][$key]; - if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { - print $langs->trans("AdvTgtMinVal") . ''; - print $langs->trans("AdvTgtMaxVal") . ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { - print ''; - print '
    ' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate('', 'options_' . $key . '_st_dt'); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate('', 'options_' . $key . '_end_dt'); - print '
    '; - - print '
    ' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { - print $form->selectarray( - 'options_' . $key, - array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), - $array_query['options_' . $key] - ); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { - print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { - print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); - print '' . "\n"; - } else { - print ''; - print '
    '; - if (is_array($array_query['options_' . $key])) { - print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); - } else { - print $extrafields->showInputField($key, $array_query['options_' . $key]); - } - print '
    '; - - print '
    ' . "\n"; - } - print '
    ' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); - if (count($array_query['contact_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray( - 'contact_status', - array ( - '0' => $langs->trans('ActivityCeased'), - '1' => $langs->trans('InActivity') - ), - $array_query['contact_status'] - ); - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); - print '
    ' . $langs->trans("UserTitle"); - if (count($array_query['contact_civility']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); - print '
    ' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); - if (! empty($array_query['contact_lastname'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); - if (! empty($array_query['contact_firstname'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
    ' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); - if (count($array_query['contact_country']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); - print '' . "\n"; - print '
    ' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); - if (! empty($array_query['contact_no_email'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->selectarray( - 'contact_no_email', - array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), - $array_query['contact_no_email'] - ); - print '' . "\n"; - print '
    ' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); - if (! empty($array_query['contact_create_st_dt'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '
    ' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); - print '
    '; - print '
    ' . "\n"; - print '
    ' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); - if (! empty($array_query['contact_update_st_dt'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '
    ' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); - print '
    '; - print '
    ' . "\n"; - print '
    ' . $langs->trans("ContactCategoriesShort"); - if (count($array_query['contact_categ']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); - print '' . "\n"; - print '
    ' . $extrafields->attributes[$elementtype]['label'][$key]; - if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { - print $langs->trans("AdvTgtMinVal") . ''; - print $langs->trans("AdvTgtMaxVal") . ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { - print ''; - print '
    ' . $langs->trans("AdvTgtStartDt") . ''; - print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct'); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct'); - print '
    '; - - print '
    ' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { - print $form->selectarray( - 'options_' . $key . '_cnct', - array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), - $array_query['options_' . $key . '_cnct'] - ); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { - print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); - print '' . "\n"; - } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { - print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); - print '' . "\n"; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { + print $form->selectarray( + 'options_' . $key, + array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), + $array_query['options_' . $key] + ); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } else { + print ''; + print '' . "\n"; + print '
    '; + if (is_array($array_query['options_' . $key])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); } else { - print ''; - print '
    '; - if (is_array($array_query['options_' . $key . '_cnct'])) { - print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); - } else { - print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); - } - print '
    '; - - print '
    ' . "\n"; + print $extrafields->showInputField($key, $array_query['options_' . $key]); } - print '
    '; + + print '
    ' . "\n"; } + print '
    ' . "\n"; + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + $hookmanager->initHooks(array ('thirdpartycard')); - print '' . "\n"; + $parameters=array(); + if (! empty($advTarget->id)) { + $parameters = array('array_query' => $advTarget->filtervalue); + } + // Other attributes + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); + print $hookmanager->resPrint; +} - print '
    ' . "\n"; - print '
    ' . "\n"; - print '
    ' . "\n"; +// State Contact +print '' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); +if (count($array_query['contact_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->advMultiselectarray( + 'contact_status', + array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), + $array_query['contact_status'] +); +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); +print '' . "\n"; - print '
    '; - print ''; - print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere")); - print ''; - print ''; - print ''; - print ''; - print '
    '; - print '
    '; - print '
    '; +// Civility +print '' . $langs->trans("UserTitle"); +if (count($array_query['contact_civility']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print ''; +print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); +print ''; + +// contact name +print '' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); +if (! empty($array_query['contact_lastname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '' . "\n"; +print '' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); +if (! empty($array_query['contact_firstname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); +print '' . "\n"; + +// Contact Country +print '' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); +if (count($array_query['contact_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); +print '' . "\n"; +print '' . "\n"; + +// Never send mass mailing +print '' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); +if (! empty($array_query['contact_no_email'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print $form->selectarray( + 'contact_no_email', + array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), + $array_query['contact_no_email'] +); +print '' . "\n"; +print '' . "\n"; + +// Contact Date Create +print '' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); +if (! empty($array_query['contact_create_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print ''; +print '
    ' . $langs->trans("AdvTgtStartDt") . ''; +print $form->selectDate($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); +print '' . $langs->trans("AdvTgtEndDt") . ''; +print $form->selectDate($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); +print '
    '; +print '' . "\n"; +print '' . "\n"; + +// Contact update Create +print '' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); +if (! empty($array_query['contact_update_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); +} +print '' . "\n"; +print ''; +print '
    ' . $langs->trans("AdvTgtStartDt") . ''; +print $form->selectDate($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); +print '' . $langs->trans("AdvTgtEndDt") . ''; +print $form->selectDate($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); +print '
    '; +print '' . "\n"; +print '' . "\n"; + +if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . $langs->trans("ContactCategoriesShort"); + if (count($array_query['contact_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); + print '' . "\n"; + print '' . "\n"; +} + +// Standard Extrafield feature +if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $elementype=Contact::$table_element; + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($elementype); + foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) { + if($value == 'radio')$value = 'select'; + } + + foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) { + print '' . $extrafields->attributes[$elementtype]['label'][$key]; + if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { + print ''; + print '
    ' . $langs->trans("AdvTgtStartDt") . ''; + print $form->selectDate('', 'options_' . $key . '_st_dt' . '_cnct'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->selectDate('', 'options_' . $key . '_end_dt' . '_cnct'); + print '
    '; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) { + print $form->selectarray( + 'options_' . $key . '_cnct', + array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), + $array_query['options_' . $key . '_cnct'] + ); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } else { + print ''; + print '
    '; + if (is_array($array_query['options_' . $key . '_cnct'])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); + } else { + print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); + } + print '
    '; + print '' . "\n"; + } + print '' . "\n"; + } +} +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '' . "\n"; +print '

    ' . "\n"; +print '
    '; +print ''; +print load_fiche_titre($langs->trans("ToClearAllRecipientsClickHere")); +print ''; +print ''; +print ''; +print ''; +print '
    '; +print '
    '; +print '
    '; diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index ca2cd9e1fd7..821881314d3 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -67,7 +67,7 @@ $userstatic=new User($db); + ?>
    trans("NatureOfContact"); ?>
    trans("ThirdParty"); ?>
    @@ -81,13 +81,13 @@ if ($permission) { if (empty($hideaddcontactforuser)) { - ?> + ?> " /> - '; ?> + '; ?>
    trans("Users"); ?>
    global->MAIN_INFO_SOCIETE_NOM; ?>
    select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?>
    @@ -101,19 +101,19 @@ if ($permission) {
    ">
    - + ?>
    " /> - '; ?> + '; ?>
    trans("ThirdPartyContacts"); ?>
    socid; ?> @@ -141,7 +141,7 @@ if ($permission) {
    - @@ -155,21 +155,21 @@ if ($permission) {
     
    - element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; +$arrayofsource=array('internal','external'); // Show both link to user and thirdparties contacts +foreach($arrayofsource as $source) { + $tmpobject=$object; + if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; - $tab = $tmpobject->liste_contact(-1, $source); - $num=count($tab); + $tab = $tmpobject->liste_contact(-1, $source); + $num=count($tab); - $i = 0; - while ($i < $num) { - $var = ! $var; - ?> + $i = 0; + while ($i < $num) { + $var = ! $var; + ?>
    @@ -177,75 +177,68 @@ if ($permission) { trans("ThirdPartyContact"); ?>
    - 0) - { - $companystatic->fetch($tab[$i]['socid']); - echo $companystatic->getNomUrl(1); - } - if ($tab[$i]['socid'] < 0) - { - echo $conf->global->MAIN_INFO_SOCIETE_NOM; - } - if (! $tab[$i]['socid']) - { - echo ' '; - } - ?> + 0) + { + $companystatic->fetch($tab[$i]['socid']); + echo $companystatic->getNomUrl(1); + } + if ($tab[$i]['socid'] < 0) + { + echo $conf->global->MAIN_INFO_SOCIETE_NOM; + } + if (! $tab[$i]['socid']) + { + echo ' '; + } + ?>
    - fetch($tab[$i]['id']); - echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); - } - if ($tab[$i]['source']=='external') - { - $contactstatic->fetch($tab[$i]['id']); - echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); - } - ?> + if ($tab[$i]['source']=='internal') + { + $userstatic->fetch($tab[$i]['id']); + echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); + } + if ($tab[$i]['source']=='external') + { + $contactstatic->fetch($tab[$i]['id']); + echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); + } + ?>
    - - +} -
    -
    - -initHooks(array('contacttpl')); - $parameters=array(); - $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); - } -?> - +print "\n"; +print "\n"; +print "\n"; +if (is_object($hookmanager)) { + $hookmanager->initHooks(array('contacttpl')); + $parameters=array(); + $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); +} +print "\n"; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 2a0fe46dfdd..ba0c550debc 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -63,19 +63,17 @@ if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_ $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty($conf->global->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$conf->global->THEME_ELDY_TOPMENU_BACK1):(empty($user->conf->THEME_ELDY_TOPMENU_BACK1)?$colorbackhmenu1:$user->conf->THEME_ELDY_TOPMENU_BACK1); $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' -?> - +print "\n"; -global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { // For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random' -?> + ?> - + ?> global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> - @@ -179,7 +177,7 @@ if ($captcha) { if (preg_match('/\?/', $php_self)) $php_self.='&time='.dol_print_date(dol_now(), 'dayhourlog'); else $php_self.='?time='.dol_print_date(dol_now(), 'dayhourlog'); // TODO: provide accessible captcha variants -?> + ?>
    @@ -279,11 +277,11 @@ if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->fil // Show error message if defined if (! empty($_SESSION['dol_loginmesg'])) { -?> + ?> -global->MAIN_EASTER_EGG_COMMITSTRIP)) { + ?>
    - @@ -362,7 +360,7 @@ if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLI { if (empty($conf->dol_use_jmobile)) { -?> + ?>

    -
    -
    + diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index cb8138eedae..73d86fa56a5 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -90,13 +90,11 @@ if (!empty($extrafields)) } } -?> - -\n"; $nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { -?> + ?> global->MAIN_VIEW_LINE_NUMBER)) { ?> @@ -107,9 +105,9 @@ if ($nolinesbefore) { element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { - ?> + ?> trans('SupplierRef'); ?> - trans('VAT'); ?> @@ -156,109 +154,109 @@ if ($nolinesbefore) { ?>   - global->MAIN_VIEW_LINE_NUMBER)) { - $coldisplay++; - echo ''; - } +$coldisplay=0; +// Adds a line numbering column +if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay++; - ?> + echo ''; +} + +$coldisplay++; +?> - global->MAIN_DISABLE_FREE_LINES)) +$freelines = false; +if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) +{ + $freelines = true; + $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) + if ($object->element == 'contrat') { - $freelines = true; - $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) - if ($object->element == 'contrat') - { - if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set - elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; - } - - // Free line - echo ''; - // Show radio free line - if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - echo ''; - echo ' '; - } - else - { - echo ''; - // Show type selector - if ($forceall >= 0) - { - if (empty($conf->product->enabled) || empty($conf->service->enabled)) echo $langs->trans("Type"); - else echo $langs->trans("FreeLineOfType"); - echo ' '; - } - } - - echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall); - - echo ''; + if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set + elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; } - // Predefined product/service - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + // Free line + echo ''; + // Show radio free line + if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) { - if ($forceall >= 0 && $freelines) echo '
    '; - echo ''; - echo ''; +} + +// Predefined product/service +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +{ + if ($forceall >= 0 && $freelines) echo '
    '; + echo ''; + echo ''; + echo ' '; + + $filtertype=''; + if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + + if (empty($senderissupplier)) + { + $statustoshow = 1; + if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) + { + // hide products in closed warehouse, but show products for internal transfer + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); } else { - if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('PredefinedProductsToPurchase'); - elseif (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('PredefinedServicesToPurchase'); - else echo $langs->trans('PredefinedProductsAndServicesToPurchase'); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); } - echo ''; - echo ' '; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; - - if (empty($senderissupplier)) + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) { - $statustoshow = 1; - if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) - { - // hide products in closed warehouse, but show products for internal transfer - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); - } - else - { - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); - } - - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) - { - ?> + ?> - array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key - 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done - 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) - ); - $alsoproductwithnosupplierprice=0; - } - else - { - $ajaxoptions = array( - 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key - ); - $alsoproductwithnosupplierprice=1; - } + array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key + 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done + 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) + ); + $alsoproductwithnosupplierprice=0; + } + else + { + $ajaxoptions = array( + 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key + ); + $alsoproductwithnosupplierprice=1; + } - $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); + $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) - { - ?> + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { + ?> - '; - echo ''; + '; + echo '
    '; +} + +if (is_object($hookmanager) && empty($senderissupplier)) +{ + $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); + $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } +} +if (is_object($hookmanager) && ! empty($senderissupplier)) +{ + $parameters=array('htmlname'=>'addproduct'); + $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } +} + + +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { + if (!empty($conf->variants->enabled)) { + echo '
    '; } - if (is_object($hookmanager) && empty($senderissupplier)) - { - $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); - $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); - if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; - } - } - if (is_object($hookmanager) && ! empty($senderissupplier)) - { - $parameters=array('htmlname'=>'addproduct'); - $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); - if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; - } - } + echo '
    '; +} +// Editor wysiwyg +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +$nbrows=ROWS_2; +$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); +if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; +$toolbarname='dolibarr_details'; +if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; +$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); +$doleditor->Create(); - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - if (!empty($conf->variants->enabled)) { - echo '
    '; - } +// Show autofill date for recurring invoices +if (! empty($conf->service->enabled) && $object->element == 'facturerec') +{ + echo '

    '; + echo $langs->trans('AutoFillDateFrom').' '; + echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); + echo ' - '; + echo $langs->trans('AutoFillDateTo').' '; + echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); + echo '
    '; +} +echo ''; - echo '
    '; - } - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $toolbarname='dolibarr_details'; - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; - $doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); - $doleditor->Create(); - - // Show autofill date for recurring invoices - if (! empty($conf->service->enabled) && $object->element == 'facturerec') - { - echo '

    '; - echo $langs->trans('AutoFillDateFrom').' '; - echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); - echo ' - '; - echo $langs->trans('AutoFillDateTo').' '; - echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); - echo '
    '; - } - echo ''; - - if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines - { - $coldisplay++; - ?> - "> - - - element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines +{ $coldisplay++; - if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); - ?> + ?> + "> +'; +$coldisplay++; +if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); +else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); +?> "> - multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { - $coldisplay++; +multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + $coldisplay++; ?> "> - + "> - +$coldisplay++; +?> "> - global->PRODUCT_USE_UNITS) - { - $coldisplay++; - print ''; - print $form->selectUnits($line->fk_unit, "units"); - print ''; - } - $remise_percent = $buyer->remise_percent; - if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') - { - $remise_percent = $seller->remise_supplier_percent; - } +global->PRODUCT_USE_UNITS) +{ + $coldisplay++; + print ''; + print $form->selectUnits($line->fk_unit, "units"); + print ''; +} +$remise_percent = $buyer->remise_percent; +if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') +{ + $remise_percent = $seller->remise_supplier_percent; +} - $coldisplay++; - ?> +$coldisplay++; +?> ">% - situation_cycle_ref) { - $coldisplay++; - print '%'; - $coldisplay++; - print ''; - } +if ($this->situation_cycle_ref) { + $coldisplay++; + print '%'; + $coldisplay++; + print ''; +} - if (! empty($usemargins)) - { - if (!empty($user->rights->margins->creer)) { - $coldisplay++; - ?> +if (! empty($usemargins)) +{ + if (!empty($user->rights->margins->creer)) { + $coldisplay++; + ?> - product->enabled) || ! empty($conf->service->enabled)) { ?> + product->enabled) || ! empty($conf->service->enabled)) { ?> - + "> - global->DISPLAY_MARGIN_RATES)) - { - echo '%'; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) - { - echo '%'; - $coldisplay++; - } + global->DISPLAY_MARGIN_RATES)) + { + echo '%'; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo '%'; + $coldisplay++; } } +} - $coldisplay+=$colspan; - ?> +$coldisplay+=$colspan; +?> @@ -512,37 +510,33 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");'; } } - print '' - ?> - - -'; + print ''; + print "\n"; } -?> -'; - print '
    '; - print ''; - // Load shipments already done for same order $object->loadExpeditions(); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 217497a962e..918266eab90 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -57,11 +57,12 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
    '; print '
    '; print ''; print ''; - print "
    '.$langs->trans("Search").'
    '; print $langs->trans("Shipment").':

    \n"; + print "
    \n"; } /* @@ -92,6 +93,7 @@ if ($resql) $num = $db->num_rows($resql); if ($num) { + print '
    '; print ''; print ''; print ''; @@ -115,7 +117,7 @@ if ($resql) print ''; $i++; } - print "
    '.$langs->trans("SendingsToValidate").'

    "; + print "

    "; } } @@ -143,6 +145,7 @@ if ($resql) $langs->load("orders"); $i = 0; + print '
    '; print ''; print ''; print ''; @@ -172,7 +175,7 @@ if ($resql) print ''; $i++; } - print "
    '.$langs->trans("OrdersToProcess").'

    "; + print "

    "; } } @@ -203,6 +206,7 @@ if ( $resql ) if ($num) { $i = 0; + print '
    '; print ''; print ''; print ''; @@ -231,7 +235,7 @@ if ( $resql ) print ''; $i++; } - print "
    '.$langs->trans("OrdersInProcess").'

    "; + print "

    "; } } else dol_print_error($db); @@ -262,6 +266,7 @@ if ($resql) if ($num) { $i = 0; + print '
    '; print ''; print ''; print ''; @@ -288,7 +293,7 @@ if ($resql) print ''; $i++; } - print "
    '.$langs->trans("LastSendings", $num).'

    "; + print "

    "; } $db->free($resql); } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 293c00a2319..a5c9125d844 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -288,19 +288,20 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index a632584a510..8e27db03b45 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -23,11 +23,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; -load("sendings"); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Shipment"); ?> getNomUrl(1); ?> date_delivery, 'day'); ?> rights->expedition->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->expedition->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> $objectlink) } ?> - 1) { ?> @@ -81,6 +80,5 @@ if (count($linkedObjectBlock) > 1) { - +print "\n"; diff --git a/htdocs/expensereport/ajax/ajaxprojet.php b/htdocs/expensereport/ajax/ajaxprojet.php index e3872577473..77b6968a38a 100644 --- a/htdocs/expensereport/ajax/ajaxprojet.php +++ b/htdocs/expensereport/ajax/ajaxprojet.php @@ -69,8 +69,8 @@ if (GETPOST('fk_projet') != '') { $label=$row['ref'].' - '.$row['title']; $row_array['label'] = $label; - $row_array['value'] = $label; - $row_array['key'] = $row['rowid']; + $row_array['value'] = $label; + $row_array['key'] = $row['rowid']; array_push($return_arr, $row_array); } diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index e635fd1e1fb..485373c5840 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -972,10 +972,10 @@ class ExpenseReport extends CommonObject $num = $this->db->num_rows($result); $i = 0; while ($i < $num): - $objp = $this->db->fetch_object($result); - $total_ht+=$objp->total_ht; - $total_tva+=$objp->total_tva; - $i++; + $objp = $this->db->fetch_object($result); + $total_ht+=$objp->total_ht; + $total_tva+=$objp->total_tva; + $i++; endwhile; $total_ttc = $total_ht + $total_tva; @@ -985,13 +985,13 @@ class ExpenseReport extends CommonObject $sql.= " , total_tva = ".$total_tva; $sql.= " WHERE rowid = ".$id; $result = $this->db->query($sql); - if($result): - $this->db->free($result); - return 1; + if ($result): + $this->db->free($result); + return 1; else: - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR); - return -3; + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR); + return -3; endif; } else @@ -1276,10 +1276,10 @@ class ExpenseReport extends CommonObject $this->date_debut = $this->db->jdate($objp->date_debut); - if ($this->fk_statut != 2) + if ($this->fk_statut != self::STATUS_VALIDATED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = 2"; + $sql.= " SET fk_statut = ".self::STATUS_VALIDATED; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_save_from_refuse sql=".$sql, LOG_DEBUG); @@ -1314,11 +1314,12 @@ class ExpenseReport extends CommonObject // date approval $this->date_approve = $now; - if ($this->fk_statut != 5) { - $this->db->begin(); + if ($this->fk_statut != self::STATUS_APPROVED) + { + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 5, fk_user_approve = ".$fuser->id.","; + $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_APPROVED.", fk_user_approve = ".$fuser->id.","; $sql.= " date_approve='".$this->db->idate($this->date_approve)."'"; $sql.= ' WHERE rowid = '.$this->id; if ($this->db->query($sql)) @@ -1375,10 +1376,10 @@ class ExpenseReport extends CommonObject $error = 0; // date de refus - if ($this->fk_statut != 99) + if ($this->fk_statut != self::STATUS_REFUSED) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 99, fk_user_refuse = ".$fuser->id.","; + $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = ".self::STATUS_REFUSED.", fk_user_refuse = ".$fuser->id.","; $sql.= " date_refuse='".$this->db->idate($now)."',"; $sql.= " detail_refuse='".$this->db->escape($details)."',"; $sql.= " fk_user_approve = NULL"; @@ -1444,7 +1445,7 @@ class ExpenseReport extends CommonObject $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET paid = 0"; + $sql.= " SET paid = 0, fk_statut = ".self::STATUS_APPROVED; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); @@ -1501,12 +1502,12 @@ class ExpenseReport extends CommonObject // phpcs:enable $error = 0; $this->date_cancel = $this->db->idate(gmmktime()); - if ($this->fk_statut != ExpenseReport::STATUS_CANCELED) + if ($this->fk_statut != self::STATUS_CANCELED) { $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_statut = ".ExpenseReport::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; + $sql.= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id; $sql.= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; $sql.= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql.= ' WHERE rowid = '.$this->id; @@ -1695,10 +1696,10 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -1725,10 +1726,10 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -2372,10 +2373,10 @@ class ExpenseReport extends CommonObject $response = new WorkboardResponse(); if ($option == 'toapprove') { - $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24; - $response->label=$langs->trans("ExpenseReportsToApprove"); - $response->labelShort=$langs->trans("ToApprove"); - $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut=2'; + $response->warning_delay=$conf->expensereport->approve->warning_delay/60/60/24; + $response->label=$langs->trans("ExpenseReportsToApprove"); + $response->labelShort=$langs->trans("ToApprove"); + $response->url=DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&statut=2'; } else { diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index cecbae9757a..aaffc878046 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -3,8 +3,9 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric FRANCE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -133,6 +134,8 @@ if ($conf->use_javascript_ajax) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); + $dolgraph->setHeight(350); + $dolgraph->combine = empty($conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT)?0.05:$conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT; $dolgraph->setShowLegend(1); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index ecf32df6740..5a0bb291596 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -537,8 +537,9 @@ if ($resql) if (! empty($arrayfields['d.date_debut']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } print ''; $formother->select_year($year_start, 'year_start', 1, $min_year, $max_year); @@ -548,9 +549,10 @@ if ($resql) if (! empty($arrayfields['d.date_fin']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) - print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { + print ''; + } + print ''; $formother->select_year($year_end, 'year_end', 1, $min_year, $max_year); print ''; } @@ -577,12 +579,12 @@ if ($resql) } if (! empty($arrayfields['d.total_vat']['checked'])) { - print ''; + print ''; } // Amount with all taxes if (! empty($arrayfields['d.total_ttc']['checked'])) { - print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index ee543d40cc5..009b1b9ea75 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -24,37 +24,34 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) { -?> + ?> > trans("ExpenseReport"); ?> getNomUrl(1); ?> date_debut, 'day'); ?> rights->expensereport->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->expensereport->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - - +print "\n"; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 1941c321458..1ed9432ffb0 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1196,19 +1196,20 @@ elseif ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->ficheinter->creer) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 494a1156b4f..1a43bf8e9f8 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -141,20 +141,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->ficheinter->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index b6d70669cc7..f9f67d5a05b 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -120,21 +120,22 @@ if ($object->id) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { if (! empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index d7ba3a3c178..954027a99da 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -86,20 +86,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php index ea69d287880..95c67f987f5 100644 --- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php @@ -22,11 +22,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; -load("interventions"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$ilink=0; +$ilink = 0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Intervention"); ?> getNomUrl(1); ?> @@ -54,8 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink) getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - - +print "\n"; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 23e6802fd0c..de31ae1b624 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -790,48 +790,40 @@ if ($object->id > 0) if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) { $langs->load("supplier_proposal"); - if ($object->status == 1) - { - print ''.$langs->trans("AddSupplierProposal").''; - } - else - { - print ''.$langs->trans("AddSupplierProposal").''; - } + if ($object->status == 1) { + print ''.$langs->trans("AddSupplierProposal").''; + } else { + print ''.$langs->trans("AddSupplierProposal").''; + } } if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); - if ($object->status == 1) - { - print ''.$langs->trans("AddOrder").''; - } - else - { - print ''.$langs->trans("AddOrder").''; - } + if ($object->status == 1) { + print ''.$langs->trans("AddOrder").''; + } else { + print ''.$langs->trans("AddOrder").''; + } } if ($user->rights->fournisseur->facture->creer) { $langs->load("bills"); - if ($object->status == 1) - { - print ''.$langs->trans("AddBill").''; - } - else - { - print ''.$langs->trans("AddBill").''; - } + if ($object->status == 1) { + print ''.$langs->trans("AddBill").''; + } else { + print ''.$langs->trans("AddBill").''; + } } if ($user->rights->fournisseur->facture->creer) { if (! empty($orders2invoice) && $orders2invoice > 0) { - if ($object->status == 1) // Company is open + if ($object->status == 1) { + // Company is open print ''; } else diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index fb9539f6e62..a6d4751169e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1272,7 +1272,8 @@ class CommandeFournisseur extends CommonOrder { $this->special_code = $this->lines[$i]->special_code; // TODO : remove this in 9.0 and add special_code param to addline() - $result = $this->addline( // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set + // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set + $result = $this->addline( $this->lines[$i]->desc, $this->lines[$i]->subprice, $this->lines[$i]->qty, diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index dfdc743de85..3ea59695819 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2361,10 +2361,10 @@ class FactureFournisseur extends CommonInvoice return $numref; } else - { - $this->error=$obj->error; - //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); - return false; + { + $this->error=$obj->error; + //dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error); + return false; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 1d8f385fd05..97ce70a8a28 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ion Agorria - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -647,95 +647,96 @@ if (empty($reshook)) // Define info_bits $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) - $info_bits |= 0x01; + if (preg_match('/\*/', $vat_rate)) { + $info_bits |= 0x01; + } - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); - $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); + $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); - if (GETPOST('price_ht') != '') + if (GETPOST('price_ht') != '') + { + $price_base_type = 'HT'; + $ht = price2num(GETPOST('price_ht')); + } + else + { + $vatratecleaned = $vat_rate; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht')); - } - else - { - $vatratecleaned = $vat_rate; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" - { - $vatratecleaned = trim($reg[1]); - $vatratecode = $reg[2]; - } - - $ttc = price2num(GETPOST('price_ttc')); - $ht = $ttc / (1 + ($vatratecleaned / 100)); - $price_base_type = 'HT'; + $vatratecleaned = trim($reg[1]); + $vatratecode = $reg[2]; } - $pu_ht_devise = GETPOST('multicurrency_subprice'); + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($vatratecleaned / 100)); + $price_base_type = 'HT'; + } - // Extrafields Lines - $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); - } + $pu_ht_devise = GETPOST('multicurrency_subprice'); + + // Extrafields Lines + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); } + } - $result = $object->updateline( - $lineid, - $_POST['product_desc'], - $ht, - $_POST['qty'], - $_POST['remise_percent'], - $vat_rate, - $localtax1_rate, - $localtax2_rate, - $price_base_type, - 0, - isset($_POST["type"])?$_POST["type"]:$line->product_type, - false, - $date_start, - $date_end, - $array_options, - $_POST['units'], - $pu_ht_devise, - GETPOST('fourn_ref', 'alpha') - ); - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprodfournprice']); - unset($_POST['remmise_percent']); - unset($_POST['dp_desc']); - unset($_POST['np_desc']); - unset($_POST['pu']); - unset($_POST['fourn_ref']); - unset($_POST['tva_tx']); - unset($_POST['date_start']); - unset($_POST['date_end']); - unset($_POST['units']); - unset($localtax1_tx); - unset($localtax2_tx); + $result = $object->updateline( + $lineid, + $_POST['product_desc'], + $ht, + $_POST['qty'], + $_POST['remise_percent'], + $vat_rate, + $localtax1_rate, + $localtax2_rate, + $price_base_type, + 0, + isset($_POST["type"])?$_POST["type"]:$line->product_type, + false, + $date_start, + $date_end, + $array_options, + $_POST['units'], + $pu_ht_devise, + GETPOST('fourn_ref', 'alpha') + ); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprodfournprice']); + unset($_POST['remmise_percent']); + unset($_POST['dp_desc']); + unset($_POST['np_desc']); + unset($_POST['pu']); + unset($_POST['fourn_ref']); + unset($_POST['tva_tx']); + unset($_POST['date_start']); + unset($_POST['date_end']); + unset($_POST['units']); + unset($localtax1_tx); + unset($localtax2_tx); - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); - if ($result >= 0) - { + if ($result >= 0) + { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -753,12 +754,12 @@ if (empty($reshook)) $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db, $result); } - } - else - { + } + else + { dol_print_error($db, $object->error); exit; - } + } } // Remove a product line @@ -2500,13 +2501,13 @@ elseif (! empty($object->id)) // Create bill //if (! empty($conf->facture->enabled)) //{ - if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + if (! empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + { + if ($user->rights->fournisseur->facture->creer) { - if ($user->rights->fournisseur->facture->creer) - { - print ''.$langs->trans("CreateBill").''; - } + print ''.$langs->trans("CreateBill").''; } + } //} // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index ca5ad3988fc..4db112bcb0f 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -157,20 +157,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 7aa50456e3a..0884a416d65 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -407,20 +407,21 @@ if ($id > 0 || ! empty($ref)) { $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); @@ -462,8 +463,8 @@ if ($id > 0 || ! empty($ref)) { print '' . $author->getNomUrl(1, '', 0, 0, 0) . ''; print ''; - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print ""; diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index aece9d02014..6ebb83a25dc 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -126,20 +126,21 @@ if ($object->id > 0) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 45f04b865ea..8b0b17c066b 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -122,20 +122,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index d2c262d2e7a..61e4029f795 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -103,20 +103,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index cd242faac6a..f1b0d3995eb 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -436,7 +436,7 @@ if (($action != 'create' && $action != 'add') && !$error) { }); }); - - +print "\n"; -load("orders"); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("SupplierOrder"); ?> trans("ShowOrder"), "order").' '.$objectlink->ref; ?> ref_supplier; ?> date, 'day'); ?> rights->fournisseur->commande->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->fournisseur->commande->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - 1) { @@ -74,6 +73,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a724cf013eb..0949b85bd7d 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2002-2005 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García * Copyright (C) 2016-2017 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2019 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -308,18 +308,20 @@ if (empty($reshook)) // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $ret = $object->fetch($object->id); // Reload to get new records - $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } + } + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $ret = $object->fetch($object->id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } } } @@ -1017,97 +1019,97 @@ if (empty($reshook)) { $db->begin(); - $object->fetch($id); - $object->fetch_thirdparty(); + $object->fetch($id); + $object->fetch_thirdparty(); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - if (GETPOST('price_ht') != '') - { - $up = price2num(GETPOST('price_ht')); - $price_base_type = 'HT'; - } - else - { - $up = price2num(GETPOST('price_ttc')); - $price_base_type = 'TTC'; - } + if (GETPOST('price_ht') != '') + { + $up = price2num(GETPOST('price_ht')); + $price_base_type = 'HT'; + } + else + { + $up = price2num(GETPOST('price_ttc')); + $price_base_type = 'TTC'; + } - if (GETPOST('productid') > 0) + if (GETPOST('productid') > 0) + { + $productsupplier = new ProductFournisseur($db); + if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { - $productsupplier = new ProductFournisseur($db); - if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) + if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0 ) { - if (GETPOST('productid') > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), GETPOST('productid'), 'none', GETPOST('socid', 'int')) < 0 ) - { - setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); - } - } - - $prod = new Product($db); - $prod->fetch(GETPOST('productid')); - $label = $prod->description; - if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; - - $type = $prod->type; - } - else - { - $label = $_POST['product_desc']; - $type = $_POST["type"]?$_POST["type"]:0; - } - - $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); - $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $tva_tx)) - $info_bits |= 0x01; - - // Define vat_rate - $tva_tx = str_replace('*', '', $tva_tx); - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - - $remise_percent=GETPOST('remise_percent'); - $pu_ht_devise = GETPOST('multicurrency_subprice'); - - // Extrafields Lines - $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_" . $key]); + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); - if ($result >= 0) - { - unset($_POST['label']); - unset($_POST['fourn_ref']); - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + $prod = new Product($db); + $prod->fetch(GETPOST('productid')); + $label = $prod->description; + if (trim($_POST['product_desc']) != trim($label)) $label=$_POST['product_desc']; - $db->commit(); - } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); + $type = $prod->type; + } + else + { + $label = $_POST['product_desc']; + $type = $_POST["type"]?$_POST["type"]:0; + } + + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $tva_tx)) + $info_bits |= 0x01; + + // Define vat_rate + $tva_tx = str_replace('*', '', $tva_tx); + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); + + $remise_percent=GETPOST('remise_percent'); + $pu_ht_devise = GETPOST('multicurrency_subprice'); + + // Extrafields Lines + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_" . $key]); } + } + + $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise, GETPOST('fourn_ref', 'alpha')); + if ($result >= 0) + { + unset($_POST['label']); + unset($_POST['fourn_ref']); + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + + $db->commit(); + } + else + { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } } elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) @@ -1654,52 +1656,52 @@ if ($action == 'create') $element = 'projet'; } - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'order_supplier') { - $element = 'fourn'; $subelement = 'fournisseur.commande'; - } + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'order_supplier') { + $element = 'fourn'; $subelement = 'fournisseur.commande'; + } - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $objectsrc = new $classname($db); - $objectsrc->fetch($originid); - $objectsrc->fetch_thirdparty(); + require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $objectsrc = new $classname($db); + $objectsrc->fetch($originid); + $objectsrc->fetch_thirdparty(); - $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); - //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); - $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); - $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); - $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); - $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; + $soc = $objectsrc->thirdparty; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:0)); // TODO maybe add default value option + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); + $fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0)); + $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0)); + $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; - if (!empty($conf->multicurrency->enabled)) - { - if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; - if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; - } + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + } - $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); - $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); - $datedue=($datetmp==''?-1:$datetmp); + $datetmp=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); + $datetmp=dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue=($datetmp==''?-1:$datetmp); - // Replicate extrafields - $objectsrc->fetch_optionals($originid); - $object->array_options = $objectsrc->array_options; + // Replicate extrafields + $objectsrc->fetch_optionals($originid); + $object->array_options = $objectsrc->array_options; } else { @@ -2047,7 +2049,7 @@ if ($action == 'create') $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; - // print ''; + // print ''; print ''; // Private note @@ -2085,12 +2087,21 @@ if ($action == 'create') print ''.$txt.''.$objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid, $origin, '', 'invoice_supplier'); - $cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']); - if ($cntinvoice>=1) + + $invoice_supplier = $objectsrc->linkedObjects['invoice_supplier']; + + // count function need a array as argument (Note: the array must implement Countable too) + if(is_array($invoice_supplier)) { - setEventMessages('WarningBillExist', null, 'warnings'); - echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['invoice_supplier'])->getNomUrl(1).')'; + $cntinvoice = count($invoice_supplier); + + if ($cntinvoice >= 1) + { + setEventMessages('WarningBillExist', null, 'warnings'); + echo ' ('.$langs->trans('LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).')'; + } } + echo ''; print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht).''; print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva).""; @@ -2376,19 +2387,20 @@ else $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->facture->creer) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index c08178bc932..7c8a78cf8ce 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2015-2016 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2018 Charlene Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -375,10 +375,11 @@ if (! $search_all) $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; $sql.= " p.rowid, p.ref, p.title"; - - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) //prevent error with sql_mode=only_full_group_by - { - $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + //prevent error with sql_mode=only_full_group_by + $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ",ef.".$key : ''); + } } } else @@ -614,12 +615,12 @@ if ($resql) FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); -/* + /* if (! empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } -*/ + */ //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); print ''; @@ -1105,32 +1106,31 @@ if ($resql) // Show total line if (isset($totalarray['totalhtfield']) - || isset($totalarray['totalvatfield']) - || isset($totalarray['totallocaltax1field']) - || isset($totalarray['totallocaltax2field']) - || isset($totalarray['totalttcfield']) - || isset($totalarray['totalamfield']) - || isset($totalarray['totalrtpfield']) - ) - { + || isset($totalarray['totalvatfield']) + || isset($totalarray['totallocaltax1field']) + || isset($totalarray['totallocaltax2field']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print ''; $i=0; while ($i < $totalarray['nbfield']) { - $i++; - if ($i == 1) - { + $i++; + if ($i == 1) + { if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; else print ''.$langs->trans("Totalforthispage").''; - } - elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; - elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; - elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).''; - elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).''; - elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; - elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).''; - elseif ($totalarray['totalrtpfield'] == $i) print ''.price($totalarray['totalrtp']).''; - else print ''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; + elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; + elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).''; + elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).''; + elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; + elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).''; + elseif ($totalarray['totalrtpfield'] == $i) print ''.price($totalarray['totalrtp']).''; + else print ''; } print ''; } diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index ba51b4688a9..03a4dda960e 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -102,20 +102,21 @@ if ($object->id > 0) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->fournisseur->commande->creer) { - if ($action != 'classify') + if ($action != 'classify') { // $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index c68dcd98752..38136aa3b64 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -755,7 +755,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $db->free($resql); } else - { + { dol_print_error($db); } } diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index ed94fdf23d4..cc3d3084464 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -25,11 +25,9 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("SupplierInvoice"); ?> trans("ShowBill"), "bill").' '.$objectlink->ref; ?> ref_supplier; ?> date, 'day'); ?> rights->fournisseur->facture->lire) { - $sign = 1; - if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1; - if ($objectlink->statut != 3) // If not abandonned - { - $total = $total + $sign * $objectlink->total_ht; - echo price($objectlink->total_ht); - } - else - { - echo ''.price($objectlink->total_ht).''; - } - } ?> + if ($user->rights->fournisseur->facture->lire) { + $sign = 1; + if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) $sign = -1; + if ($objectlink->statut != 3) + { + // If not abandonned + $total = $total + $sign * $objectlink->total_ht; + echo price($objectlink->total_ht); + } + else + { + echo ''.price($objectlink->total_ht).''; + } + } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - 1) { @@ -85,6 +84,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index db2a3bdc38a..deee321187b 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -77,7 +77,7 @@ if ($socid > 0) $sql.= " u.login, u.rowid as userid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; - $sql.= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany + $sql.= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany $sql.= " AND f.fk_user_valid = u.rowid"; $sql.= " ORDER BY f.datef DESC"; diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index d69f1751911..32d8ed44bb4 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -359,7 +359,7 @@ llxHeader(); // Add logic to shoow/hide buttons if ($conf->use_javascript_ajax) { -?> + ?> -entity.")"; $sql.= " OR u.admin = 1"; - } - else + } else { $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + } - $sql.= " AND u.statut > 0"; - if ($filters) $sql.=$filters; + $sql.= " AND u.statut > 0"; + if ($filters) $sql.=$filters; - $resql=$this->db->query($sql); + $resql=$this->db->query($sql); - // Si pas d'erreur SQL - if ($resql) - { - $i = 0; - $tab_result = $this->holiday; - $num = $this->db->num_rows($resql); + // Si pas d'erreur SQL + if ($resql) + { + $i = 0; + $tab_result = $this->holiday; + $num = $this->db->num_rows($resql); - // Boucles du listage des utilisateurs - while($i < $num) { - $obj = $this->db->fetch_object($resql); + // Boucles du listage des utilisateurs + while($i < $num) { + $obj = $this->db->fetch_object($resql); - $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user - $tab_result[$i]['name'] = $obj->lastname; // deprecated - $tab_result[$i]['lastname'] = $obj->lastname; - $tab_result[$i]['firstname'] = $obj->firstname; - $tab_result[$i]['gender'] = $obj->gender; - $tab_result[$i]['status'] = $obj->statut; - $tab_result[$i]['employee'] = $obj->employee; - $tab_result[$i]['photo'] = $obj->photo; - $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager - //$tab_result[$i]['type'] = $obj->type; - //$tab_result[$i]['nb_holiday'] = $obj->nb_holiday; + $tab_result[$i]['rowid'] = $obj->rowid; // rowid of user + $tab_result[$i]['name'] = $obj->lastname; // deprecated + $tab_result[$i]['lastname'] = $obj->lastname; + $tab_result[$i]['firstname'] = $obj->firstname; + $tab_result[$i]['gender'] = $obj->gender; + $tab_result[$i]['status'] = $obj->statut; + $tab_result[$i]['employee'] = $obj->employee; + $tab_result[$i]['photo'] = $obj->photo; + $tab_result[$i]['fk_user'] = $obj->fk_user; // rowid of manager + //$tab_result[$i]['type'] = $obj->type; + //$tab_result[$i]['nb_holiday'] = $obj->nb_holiday; - $i++; - } - // Retoune le tableau des utilisateurs - return $tab_result; - } - else - { - // Erreur SQL - $this->errors[]="Error ".$this->db->lasterror(); - return -1; + $i++; } + // Retoune le tableau des utilisateurs + return $tab_result; + } else { + // Erreur SQL + $this->errors[]="Error ".$this->db->lasterror(); + return -1; + } } else { diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 05ddf164105..02e29774e93 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -213,7 +213,7 @@ if ($object->id) print ''; print ''."\n"; -/* + /* print ''; print '
    '; print '
    '; diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index a7efd8616f0..1d490cc8da3 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -119,75 +119,75 @@ print ''; if ($num == 0) { - print ''.$langs->trans('None').''; + print ''.$langs->trans('None').''; } else { - while ($obj = $db->fetch_object($resql)) - { - $user = new User($db); - $user->fetch($obj->fk_user); + while ($obj = $db->fetch_object($resql)) + { + $user = new User($db); + $user->fetch($obj->fk_user); - $date_start = $db->jdate($obj->date_debut, true); - $date_end = $db->jdate($obj->date_fin, true); + $date_start = $db->jdate($obj->date_debut, true); + $date_end = $db->jdate($obj->date_fin, true); - $tmpstart = dol_getdate($date_start); - $tmpend = dol_getdate($date_end); + $tmpstart = dol_getdate($date_start); + $tmpend = dol_getdate($date_end); - $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; - $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; + $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; + $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; - $halfdayinmonth = $obj->halfday; - $starthalfdayinmonth = $starthalfday; - $endhalfdayinmonth = $endhalfday; + $halfdayinmonth = $obj->halfday; + $starthalfdayinmonth = $starthalfday; + $endhalfdayinmonth = $endhalfday; - //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + //0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning - // Set date_start_gmt and date_end_gmt that are date to show for the selected month - $date_start_inmonth = $db->jdate($obj->date_debut, true); - $date_end_inmonth = $db->jdate($obj->date_fin, true); - if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) - { - $date_start_inmonth = dol_get_first_day($search_year, $search_month, true); - $starthalfdayinmonth = 'morning'; - if ($halfdayinmonth == 2) $halfdayinmonth=1; - if ($halfdayinmonth == -1) $halfdayinmonth=0; - } - if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) - { - $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1); - $endhalfdayinmonth = 'afternoon'; - if ($halfdayinmonth == 2) $halfdayinmonth=-1; - if ($halfdayinmonth == 1) $halfdayinmonth=0; - } + // Set date_start_gmt and date_end_gmt that are date to show for the selected month + $date_start_inmonth = $db->jdate($obj->date_debut, true); + $date_end_inmonth = $db->jdate($obj->date_fin, true); + if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) + { + $date_start_inmonth = dol_get_first_day($search_year, $search_month, true); + $starthalfdayinmonth = 'morning'; + if ($halfdayinmonth == 2) $halfdayinmonth=1; + if ($halfdayinmonth == -1) $halfdayinmonth=0; + } + if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) + { + $date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1); + $endhalfdayinmonth = 'afternoon'; + if ($halfdayinmonth == 2) $halfdayinmonth=-1; + if ($halfdayinmonth == 1) $halfdayinmonth=0; + } - // Leave request - $holidaystatic->id=$obj->rowid; - $holidaystatic->ref=$obj->rowid; + // Leave request + $holidaystatic->id=$obj->rowid; + $holidaystatic->ref=$obj->rowid; - print ''; - print ''; - print $holidaystatic->getNomUrl(1, 1); - print ''; - print '' . $user->getFullName($langs) . ''; - print '' . $obj->label . ''; - print '' . dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print ''; - print '' . dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print ''; - print '' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . ''; - print '' . dol_print_date($date_start_inmonth, 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; - print ''; - print '' . dol_print_date($date_end_inmonth, 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; - print ''; - print '' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . ''; - print '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . ''; - print ''; - } + print ''; + print ''; + print $holidaystatic->getNomUrl(1, 1); + print ''; + print '' . $user->getFullName($langs) . ''; + print '' . $obj->label . ''; + print '' . dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ''; + print '' . dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ''; + print '' . num_open_day($date_start, $date_end, 0, 1, $obj->halfday) . ''; + print '' . dol_print_date($date_start_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; + print ''; + print '' . dol_print_date($date_end_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; + print ''; + print '' . num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth) . ''; + print '' . dol_escape_htmltag(dolGetFirstLineOfText($obj->description)) . ''; + print ''; + } } print ''; print '
    '; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 0ea9b5ffba2..863f519231d 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -265,12 +265,12 @@ class Establishment extends CommonObject } } - /** - * Delete record - * - * @param int $id Id of record to delete - * @return int <0 if KO, >0 if OK - */ + /** + * Delete record + * + * @param int $id Id of record to delete + * @return int <0 if KO, >0 if OK + */ public function delete($id) { $this->db->begin(); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 80a9366186c..9d9d2fcd632 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -114,6 +114,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print '
    '; print ''; + print '
    '; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -126,6 +127,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
    '; + print '
    '; print '
    '; print '
    '; } diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 9edc7f018a7..6a00679fd84 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1962,15 +1962,16 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') $height='24px'; - if ($key == 'none') {//stop multiple duplicate ids with no number + if ($key == 'none') { + //stop multiple duplicate ids with no number print "\n\n\n"; print '
    ' . "\n"; print '' . "\n"; } else { - print "\n\n\n"; + print "\n\n\n"; print '
    ' . "\n"; - print '
    '."\n"; + print '
    '."\n"; } if ($pos && $pos > count($fieldssource)) // No fields diff --git a/htdocs/index.php b/htdocs/index.php index b0b04075da4..504f77d113e 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -283,26 +283,27 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT DOL_URL_ROOT.'/don/list.php?leftmenu=donations' ); // Translation lang files - $langfile=array("users", - "companies", - "prospects", - "suppliers", - "companies", - "members", - "products", - "products", - "propal", - "orders", - "bills", - "contracts", - "interventions", - "bills", - "bills", - "supplier_proposal", - "projects", - "trips", - "holiday", - "donations" + $langfile=array( + "users", + "companies", + "prospects", + "suppliers", + "companies", + "members", + "products", + "products", + "propal", + "orders", + "bills", + "contracts", + "interventions", + "bills", + "bills", + "supplier_proposal", + "projects", + "trips", + "holiday", + "donations", ); @@ -353,34 +354,34 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $showweather = (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO == 2) ? 1 : 0; -//Array that contains all WorkboardResponse classes to process them + //Array that contains all WorkboardResponse classes to process them $dashboardlines = array(); -// Do not include sections without management permission + // Do not include sections without management permission require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php'; -// Number of actions to do (late) + // Number of actions to do (late) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) { include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php'; $board = new ActionComm($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of project opened + // Number of project opened if (!empty($conf->projet->enabled) && $user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $board = new Project($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of tasks to do (late) + // Number of tasks to do (late) if (!empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) { include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; $board = new Task($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of commercial proposals opened (expired) + // Number of commercial proposals opened (expired) if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $board = new Propal($db); @@ -389,7 +390,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed"); } -// Number of commercial proposals opened (expired) + // Number of commercial proposals opened (expired) if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) { include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; $board = new SupplierProposal($db); @@ -398,14 +399,14 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed"); } -// Number of customer orders a deal + // Number of customer orders a deal if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $board = new Commande($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of suppliers orders a deal + // Number of suppliers orders a deal if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; $board = new CommandeFournisseur($db); @@ -413,7 +414,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $dashboardlines[$board->element . '_awaiting'] = $board->load_board($user, 'awaiting'); } -// Number of services enabled (delayed) + // Number of services enabled (delayed) if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $board = new Contrat($db); @@ -421,21 +422,21 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // Number of active services (expired) $dashboardlines[$board->element . '_active'] = $board->load_board($user, "active"); } -// Number of invoices customers (has paid) + // Number of invoices customers (has paid) if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $board = new Facture($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of supplier invoices (has paid) + // Number of supplier invoices (has paid) if (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->fournisseur->facture->lire)) { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; $board = new FactureFournisseur($db); $dashboardlines[$board->element] = $board->load_board($user); } -// Number of transactions to conciliate + // Number of transactions to conciliate if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id) { include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; $board = new Account($db); @@ -445,35 +446,35 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } } -// Number of cheque to send + // Number of cheque to send if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) { include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php'; $board = new RemiseCheque($db); $dashboardlines['RemiseCheque'] = $board->load_board($user); } -// Number of foundation members + // Number of foundation members if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->societe_id) { include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $board = new Adherent($db); $dashboardlines['Adherent'] = $board->load_board($user); } -// Number of expense reports to approve + // Number of expense reports to approve if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) { include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); $dashboardlines['ExpenseReport'] = $board->load_board($user, 'toapprove'); } -// Number of expense reports to pay + // Number of expense reports to pay if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) { include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; $board = new ExpenseReport($db); $dashboardlines['ExpenseReport'] = $board->load_board($user, 'topay'); } -// Number of holidays to approve + // Number of holidays to approve if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) { include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php'; $board = new Holiday($db); @@ -591,11 +592,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } -// Calculate total nb of late + // Calculate total nb of late $totallate = $totaltodo = 0; -//Remove any invalid response -//load_board can return an integer if failed or WorkboardResponse if OK + //Remove any invalid response + //load_board can return an integer if failed or WorkboardResponse if OK $valid_dashboardlines = array(); foreach ($dashboardlines as $infoKey => $tmp) { if ($tmp instanceof WorkboardResponse) { @@ -603,7 +604,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { } } -// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop + // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop foreach ($valid_dashboardlines as $board) { if ($board->nbtodolate > 0) { $totaltodo += $board->nbtodo; @@ -645,7 +646,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $boxwork .= ''; $boxwork .= '' . "\n"; -// Show dashboard + // Show dashboard $nbworkboardempty = 0; $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array(); if (!empty($valid_dashboardlines)) { @@ -1001,7 +1002,7 @@ function showWeather($totallate, $text, $options, $morecss = '') { global $conf; - $weather = getWeatherStatus($totallate); + $weather = getWeatherStatus($totallate); return img_weather($text, $weather->picto, $options, 0, $morecss); } diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index c953790f8c0..b800f5f6ad4 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -118,19 +118,21 @@ if (! empty($force_install_message)) +if (empty($dolibarr_main_url_root)) { + $dolibarr_main_document_root = detect_dolibarr_main_document_root(); +} +?> - @@ -245,9 +244,7 @@ if (! empty($force_install_message)) id="db_name" name="db_name" value="" - + > @@ -324,9 +321,7 @@ if (! empty($force_install_message)) ?> @@ -343,9 +338,7 @@ if (! empty($force_install_message)) id="db_host" name="db_host" value="" - + > @@ -391,12 +380,8 @@ if (! empty($force_install_message)) - + + > @@ -424,17 +407,16 @@ if (! empty($force_install_message)) + value=" + " + > @@ -446,12 +428,8 @@ if (! empty($force_install_message)) - + + > \n"; print "\n"; - print "
    + > " - + > " - + > trans("Examples").":
    "; ?> @@ -214,19 +217,15 @@ if (! empty($force_install_message)) - + + >
    trans("CheckToForceHttps"); ?>
    trans("DatabaseName"); ?> trans("ServerAddressDescription"); ?> @@ -360,9 +353,7 @@ if (! empty($force_install_message)) name="db_port" id="db_port" value="" - + > trans("ServerPortDescription"); ?> @@ -377,9 +368,7 @@ if (! empty($force_install_message)) id="db_prefix" name="db_prefix" value="" - + > trans("DatabasePrefixDescription"); ?> trans("CheckToCreateDatabase"); ?> @@ -410,9 +395,7 @@ if (! empty($force_install_message)) id="db_user" name="db_user" value="" - + > trans("AdminLogin"); ?> trans("AdminPassword"); ?> trans("CheckToCreateUser"); ?> @@ -478,9 +456,7 @@ if (! empty($force_install_message)) name="db_user_root" class="needroot" value="" - 0 && ! empty($force_install_databaserootlogin)) { - print ' disabled'; - } ?> + 0 && ! empty($force_install_databaserootlogin)) { print ' disabled'; } ?> > trans("DatabaseRootLoginDescription"); ?> @@ -516,9 +492,7 @@ if (! empty($force_install_message)) } // Do not autofill password for remote access print dol_escape_htmltag($autofill); ?>" - 0 && ! empty($force_install_databaserootpass)) { - print ' disabled'; // May be removed by javascript - } ?> + 0 && ! empty($force_install_databaserootpass)) { print ' disabled'; /* May be removed by javascript*/ } ?> > trans("KeepEmptyIfNoPassword"); ?> diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 13992a4c13c..3df02cdc470 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -59,7 +59,7 @@ UPDATE llx_rights_def SET subperms = 'write' WHERE perms = 'fiscalyear' AND modu ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL; ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0; -ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0; +ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0; ALTER TABLE llx_bom_bomline DROP COLUMN rank; @@ -409,32 +409,32 @@ create table llx_c_shipment_package_type rowid integer AUTO_INCREMENT PRIMARY KEY, label varchar(50) NOT NULL, -- Short name description varchar(255), -- Description - active integer DEFAULT 1 NOT NULL, -- Active or not - entity integer DEFAULT 1 NOT NULL -- Multi company id + active integer DEFAULT 1 NOT NULL, -- Active or not + entity integer DEFAULT 1 NOT NULL -- Multi company id )ENGINE=innodb; CREATE TABLE llx_mrp_mo( -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) DEFAULT '(PROV)' NOT NULL, - entity integer DEFAULT 1 NOT NULL, - label varchar(255), + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), qty real NOT NULL, - fk_warehouse integer, - fk_soc integer, - note_public text, - note_private text, - date_creation datetime NOT NULL, - tms timestamp, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - import_key varchar(14), - status integer NOT NULL, - fk_product integer NOT NULL, - date_start_planned datetime, - date_end_planned datetime, - fk_bom integer, + fk_warehouse integer, + fk_soc integer, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + fk_product integer NOT NULL, + date_start_planned datetime, + date_end_planned datetime, + fk_bom integer, fk_project integer -- END MODULEBUILDER FIELDS ) ENGINE=innodb; @@ -443,7 +443,7 @@ CREATE TABLE llx_mrp_mo( ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); -ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT fk_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); @@ -452,7 +452,7 @@ ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_bom (fk_bom); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_project (fk_project); -create table llx_mrp_myobject_extrafields +create table llx_mrp_mo_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -460,7 +460,7 @@ create table llx_mrp_myobject_extrafields import_key varchar(14) -- import key ) ENGINE=innodb; -ALTER TABLE llx_mrp_myobject_extrafields ADD INDEX idx_fk_object(fk_object); +ALTER TABLE llx_mrp_mo_extrafields ADD INDEX idx_fk_object(fk_object); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_VALIDATE','BOM validated','Executed when a BOM is validated','bom',400); diff --git a/htdocs/install/mysql/tables/llx_mrp_mo.key.sql b/htdocs/install/mysql/tables/llx_mrp_mo.key.sql index 8cda73f9450..5c218763ff6 100644 --- a/htdocs/install/mysql/tables/llx_mrp_mo.key.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.key.sql @@ -18,7 +18,7 @@ ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); -ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT fk_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 0acd25ec536..f7ed7bcade0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -175,6 +175,7 @@ DraftBills=Draft invoices CustomersDraftInvoices=Customer draft invoices SuppliersDraftInvoices=Vendor draft invoices Unpaid=Unpaid +ErrorNoPaymentDefined=Error No payment defined ConfirmDeleteBill=Are you sure you want to delete this invoice? ConfirmValidateBill=Are you sure you want to validate this invoice with reference %s? ConfirmUnvalidateBill=Are you sure you want to change invoice %s to draft status? diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index eee7d7dcfac..a55a0194632 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -44,6 +44,8 @@ BoxTitleLastActionsToDo=Latest %s actions to do BoxTitleLastContracts=Latest %s modified contracts BoxTitleLastModifiedDonations=Latest %s modified donations BoxTitleLastModifiedExpenses=Latest %s modified expense reports +BoxTitleLatestModifiedBoms=Latest %s modified BOMs +BoxTitleLatestModifiedMos=Latest %s modified Manufacturing Orders BoxGlobalActivity=Global activity (invoices, proposals, orders) BoxGoodCustomers=Good customers BoxTitleGoodCustomers=%s Good customers diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 1de5f40c79c..6bf86dac102 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -5,6 +5,7 @@ MRPArea=MRP Area MrpSetupPage=Setup of module MO MenuBOM=Bills of material LatestBOMModified=Latest %s Bills of materials modified +LatestMOModified=Latest %s Manufacturing Orders modified Bom=Bills of Material BillOfMaterials=Bill of Material BOMsSetup=Setup of module BOM diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index 6a1967bccf9..d8b5c7ed36e 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -379,7 +379,7 @@ class MailmanSpip return count($lists); } else - { + { $this->error="ADHERENT_MAILMAN_URL not defined"; return -1; } diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 17caa1bf29e..e04a5e6ecc0 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -68,9 +68,9 @@ if (!empty($enddatemonth)) // Security check if ($user->rights->margins->read->all) { - $agentid = GETPOST('agentid', 'int'); + $agentid = GETPOST('agentid', 'int'); } else { - $agentid = $user->id; + $agentid = $user->id; } $result=restrictedArea($user, 'margins'); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 8d1e04cafd2..b8f530660f1 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -360,7 +360,7 @@ if ($result) print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."
    "; + print ""; } else { diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f63067d6af8..a4aed7f668a 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -103,13 +103,13 @@ dol_fiche_head($head, 'productMargins', $titre, 0, $picto); print ''; if ($id > 0) { - print ''; - print ''; + print ''; + print ''; - if (! $sortorder) $sortorder="DESC"; - if (! $sortfield) $sortfield="f.datef"; + if (! $sortorder) $sortorder="DESC"; + if (! $sortfield) $sortfield="f.datef"; } else { print ''; diff --git a/htdocs/modulebuilder/template/core/modules/myobject/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/myobject/doc/doc_generic_myobject_odt.modules.php new file mode 100644 index 00000000000..bffc0d5c470 --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/myobject/doc/doc_generic_myobject_odt.modules.php @@ -0,0 +1,518 @@ + + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Philippe Grand + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/commande/doc/doc_generic_myobject_odt.modules.php + * \ingroup mymodule + * \brief File of class to build ODT documents for myobjects + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/myobject/modules_myobject.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_myobject_odt extends ModelePDFMyObject +{ + /** + * Issuer + * @var Societe + */ + public $emetteur; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * @var string Dolibarr version of the loaded document + */ + public $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs, $mysoc; + + // Load translation files required by the page + $langs->loadLangs(array("main","companies")); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Page size for A4 format + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf,$langs; + + // Load translation files required by the page + $langs->loadLangs(array("errors","companies")); + + $form = new Form($this->db); + + $texte = $this->description.".
    \n"; + $texte.= '
    '; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
    '.$langs->trans('ChooseProduct/Service').''; - print $form->select_produits($id, 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 'All'); - print '
    '.$langs->trans('ChooseProduct/Service').''; + print $form->select_produits($id, 'id', '', 20, 0, 1, 2, '', 1, array(), 0, 'All'); + print '
    '.$langs->trans('ChooseProduct/Service').'
    '; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
    '; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else + { + $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
    '.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
    '; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte.= '
    '; + $texte.= ''; + $texte.= '
    '; + $texte.= ''; + $texte.= '
    '; + + // Scan directories + $nbofiles=count($listoffiles); + if (! empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte.=count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte.=''; + } + + if ($nbofiles) + { + $texte.='
    '; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
    '; + $texte.= ''; + + return $texte; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to build a document on disk using the generic odt module. + * + * @param Commande $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable + global $user,$langs,$conf,$mysoc,$hookmanager; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); + + if ($conf->commande->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Commande($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db, $object->error); + return -1; + } + } + + $dir = $conf->commande->multidir_output[$object->entity]; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp=$objectref.'_'.$newfiletmp; + //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->societe->dir_temp=".$conf->societe->dir_temp; + + dol_mkdir($conf->mymodule->dir_temp); + + + // If CUSTOMER contact defined on order, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + $contactobject=null; + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } + + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='ORDER_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->commande->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet=$this->get_substitutionarray_object($object, $outputlangs); + $array_user=$this->get_substitutionarray_user($user, $outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in object as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + + $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + // Replace tags of lines + try + { + $foundtagforlines = 1; + try { + $listlines = $odfHandler->setSegment('lines'); + } + catch(OdfException $e) + { + // We may arrive here if tags for lines not present into template + $foundtagforlines = 0; + dol_syslog($e->getMessage(), LOG_INFO); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach($tmparray as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + catch(SegmentException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + $listlines->merge(); + } + $odfHandler->mergeSegment($listlines); + } + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } + } + + // Call the beforeODTSave hook + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + } catch (Exception $e) { + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); + return -1; + } + } + + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + return -1; + } + } + + return -1; + } +} diff --git a/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_advanced.php new file mode 100644 index 00000000000..dfcd1a574e7 --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_advanced.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2019 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/mod_bom_advanced.php + * \ingroup bom + * \brief File containing class for advanced numbering model of MyObject + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; + + +/** + * Class to manage customer Bom numbering rules advanced + */ +class mod_myobject_advanced extends ModeleNumRefMyObject +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var string Error message + */ + public $error = ''; + + /** + * @var string name + */ + public $name='advanced'; + + + /** + * Returns the description of the numbering model + * + * @return string Texte descripif + */ + public function info() + { + global $conf, $langs, $db; + + $langs->load("bills"); + + $form = new Form($db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
    \n"; + $texte.= '
    '; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + // Parametrage du prefix + $texte.= ''; + $texte.= ''; + + $texte.= ''; + + $texte.= ''; + + $texte.= '
    '.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
    '; + $texte.= '
    '; + + return $texte; + } + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $conf,$langs,$mysoc; + + $old_code_client=$mysoc->code_client; + $old_code_type=$mysoc->typent_code; + $mysoc->code_client='CCCCCCCCCC'; + $mysoc->typent_code='TTTTTTTTTT'; + $numExample = $this->getNextValue($mysoc, ''); + $mysoc->code_client=$old_code_client; + $mysoc->typent_code=$old_code_type; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + // We get cursor rule + $mask=$conf->global->MYMODULE_MYOBJECT_ADVANCED_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $date = ($object->date_bom ? $object->date_bom : $object->date); + + $numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', null, $date); + + return $numFinal; + } +} diff --git a/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_standard.php new file mode 100644 index 00000000000..0da53adb55f --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/myobject/mod_myobject_standard.php @@ -0,0 +1,149 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/mod_bom_standard.php + * \ingroup bom + * \brief File of class to manage MyObject numbering rules standard + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; + +/** + * Class to manage customer order numbering rules standard + */ +class mod_myobject_standard extends ModeleNumRefMyObject +{ + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + public $prefix='MYOBJECT'; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string name + */ + public $name='standard'; + + + /** + * Return description of numbering module + * + * @return string Text with description + */ + public function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + } + + + /** + * Return an example of numbering + * + * @return string Example + */ + public function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Checks if the numbers already in force in the data base do not + * cause conflicts that would prevent this numbering from working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next free value + * + * @param Product $objprod Object product + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($objprod, $object) + { + global $db,$conf; + + // D'abord on recupere la valeur max + $posindice=9; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."bom_bom"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_bom_standard::getNextValue", LOG_DEBUG); + return -1; + } + + //$date=time(); + $date=$object->date_creation; + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s", $max+1); + + dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } +} diff --git a/htdocs/modulebuilder/template/core/modules/myobject/modules_myobject.php b/htdocs/modulebuilder/template/core/modules/myobject/modules_myobject.php new file mode 100644 index 00000000000..4598a010287 --- /dev/null +++ b/htdocs/modulebuilder/template/core/modules/myobject/modules_myobject.php @@ -0,0 +1,151 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2014 Marcos García + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/bom/modules_bom.php + * \ingroup bom + * \brief File that contains parent class for boms models + * and parent class for boms numbering models + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit + + +/** + * Parent class for boms models + */ +abstract class ModelePDFMyObject extends CommonDocGenerator +{ + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { + // phpcs:enable + global $conf; + + $type = 'bom'; + $list = array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + + return $list; + } +} + + + +/** + * Parent class to manage numbering of BOMs + */ +abstract class ModeleNumRefMyObject +{ + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } + + /** + * Returns the default description of the numbering template + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoDescription"); + } + + /** + * Returns an example of numbering + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("mrp"); + return $langs->trans("NoExample"); + } + + /** + * Checks if the numbers already in force in the data base do not + * cause conflicts that would prevent this numbering from working. + * + * @return boolean false if conflict, true if ok + */ + public function canBeActivated() + { + return true; + } + + /** + * Returns next assigned value + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object we need next value for + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Returns version of numbering module + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 18cef7f75ea..742d94109e2 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2019 Frédéric France @@ -130,6 +130,7 @@ print '
    '; /* * Last modified BOM */ + $max=5; $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; @@ -179,12 +180,63 @@ else dol_print_error($db); } +/* + * Last modified MOs + */ +$max=5; + +$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status"; +$sql.= " FROM ".MAIN_DB_PREFIX."mrp_mo as a"; +$sql.= " WHERE a.entity IN (".getEntity('mo').")"; +$sql.= $db->order("a.tms", "DESC"); +$sql.= $db->plimit($max, 0); + +$resql=$db->query($sql); +if ($resql) +{ + print '
    '; + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $staticmo->id=$obj->rowid; + $staticmo->ref=$obj->ref; + $staticmo->date_modification=$obj->datem; + $staticmo->status=$obj->status; + + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } else { + print ''; + print ''; + print ''; + } + print "
    '.$langs->trans("LatestMOModified", $max).'
    '.$staticmo->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmo->getLibStatut(5).'
    ' . $langs->trans("None") . '
    "; + print "
    "; +} +else +{ + dol_print_error($db); +} print '
    '; $parameters = array('type' => $type, 'user' => $user); -$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, null); // Note that $action and $object may have been modified by hook // End of page llxFooter(); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 356ea7bb07f..0ecbefc32a7 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -463,6 +463,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } + // Validate + if ($user->rights->mrp->write && $object->status == MO::STATUS_DRAFT) + { + if (is_array($object->lines) && count($object->lines) > 0) + { + print '' . $langs->trans("Validate") . ''; + } + else + { + print '' . $langs->trans("Validate") . ''; + } + } + // Clone if (! empty($user->rights->mrp->write)) { @@ -525,17 +538,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } //Select mail models is same action as presend - /* - if (GETPOST('modelselected')) $action = 'presend'; + if (GETPOST('modelselected')) $action = 'presend'; - // Presend form - $modelmail='inventory'; - $defaulttopic='InformationMessage'; - $diroutput = $conf->product->dir_output.'/inventory'; - $trackid = 'stockinv'.$object->id; + // Presend form + $modelmail='mo'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->mrp->dir_output; + $trackid = 'mo'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - */ + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } // End of page diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b49dfd04902..2ba78b32945 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -91,12 +91,19 @@ class Product extends CommonObject public $label; /** - * Product descripion + * Product description * * @var string */ public $description; + /** + * Product other fields PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION + * + * @var string + */ + public $other; + /** * Check TYPE constants * diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index d618e40ab38..2f0714737ee 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -3,6 +3,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Regis Houssin * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2019 Juanjo Menent * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -140,7 +141,9 @@ if (GETPOST('statut', 'int')) { $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); -$sql .= $db->plimit($limit+1, $offset); +if (! $sproduct) { + $sql .= $db->plimit($limit+1, $offset); +} $resql = $db->query($sql); if ($resql) @@ -257,7 +260,7 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num, $conf->liste_limit)) + while ($i < min($num, $sproduct?$num:$conf->liste_limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 44b803571ba..5f74a971f87 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -83,17 +83,16 @@ if (! isset($_POST['datesrfc']) && ! isset($_POST['datesday']) && ! empty($conf- //$dates=dol_time_plus_duree($datee, -1, 'y'); $dates=dol_get_first_day($tmp['year'], 1); } -if ($id == '' && $projectid == '' && $ref == '') +if ($id == '' && $ref == '') { - dol_print_error('', 'Bad parameter'); - exit; + setEventMessage($langs->trans('ErrorBadParameters'), 'errors'); + header('Location: list.php'); + exit(); } $mine = $_REQUEST['mode']=='mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects -$projectid=$id; // For backward compatibility - $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -102,7 +101,7 @@ if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($ob // Security check $socid=$object->socid; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result = restrictedArea($user, 'projet', $projectid, 'projet&project'); +$result = restrictedArea($user, 'projet', $object->id, 'projet&project'); $hookmanager->initHooks(array('projectOverview')); @@ -539,7 +538,7 @@ if ($action=="addelement") elseif ($action == "unlink") { $tablename = GETPOST("tablename", "aZ09"); - $projectField = GETPOST("projectfield", "aZ09"); + $projectField = GETPOST('projectfield', 'aZ09') ? GETPOST('projectfield', 'aZ09') : 'fk_projet'; $elementselectid = GETPOST("elementselect", "int"); $result = $object->remove_element($tablename, $elementselectid, $projectField); @@ -558,7 +557,7 @@ $showdatefilter=0; if (! $showdatefilter) { print '
    '; - print '
    '; + print ''; print ''; print ''; print ''; @@ -781,7 +780,7 @@ foreach ($listofreferent as $key => $value) if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element)) { $selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300', -2, !empty($project_field)?$project_field:'fk_projet'); - if (! $selectList || ($selectList<0)) + if ($selectList<0) { setEventMessages($formproject->error, $formproject->errors, 'errors'); } @@ -789,7 +788,7 @@ foreach ($listofreferent as $key => $value) { // Define form with the combo list of elements to link $addform.='
    '; - $addform.=''; + $addform.=''; $addform.=''; $addform.=''; $addform.=''; @@ -916,7 +915,7 @@ foreach ($listofreferent as $key => $value) { if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true { - print ''; + print ''; print img_picto($langs->trans('Unlink'), 'unlink'); print ''; } diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index b8d733789fc..c16d42ae97c 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -139,6 +139,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { print ''; print ''; + print '
    '; print ''; $i=0; foreach($listofsearchfields as $key => $value) @@ -151,6 +152,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele $i++; } print '
    '; + print '
    '; print ''; print '
    '; } diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index d2f11419ef9..9b76f2b90b3 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -220,7 +220,7 @@ if ($format == 'rss') $result=readfile($outputfile); if (! $result) print 'File '.$outputfile.' was empty.'; - // header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); + // header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); exit; } else diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index f82e3549630..067c371bf67 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1878,42 +1878,37 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) //{ - print ' - - '; + print '
    '; + print ' + + -
    '; - if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
    '; - } + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
    '; + } - print ' -
    + print '
    '; + print ''; - '; + if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) + { + print '
    '; + } - if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) - { - print '
    '; - } + print '
    + +
    '; - print '
    - -
    + print ' + +
    '; - - + print '
    '; + print ''; + print ''; -
    - -
    '; - - print ''; - print ''; - - print ' -
    '; + print '
    '; //} if (! empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) @@ -2006,7 +2001,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment { print $e->getMessage(); } - ?> + ?> // Code for payment with option STRIPE_USE_NEW_CHECKOUT set // Create a Stripe client. @@ -2049,11 +2044,11 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment }); - global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - ?> + ?> // Code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION set // Create a Stripe client. @@ -2153,11 +2148,11 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment } }); - + ?> // Old code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off and STRIPE_USE_NEW_CHECKOUT off // Create a Stripe client. @@ -2209,7 +2204,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment global->STRIPE_USE_3DSECURE)) // Ask credit card directly, no 3DS test { - ?> + ?> /* Use token */ stripe.createToken(card).then(function(result) { if (result.error) { @@ -2221,11 +2216,11 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment stripeTokenHandler(result.token); } }); - + ?> /* Use 3DS source */ stripe.createSource(card).then(function(result) { if (result.error) { @@ -2237,7 +2232,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment stripeSourceHandler(result.source); } }); - }); @@ -2291,7 +2286,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment form.submit(); } - '; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 13eb53d86a6..832fd4fc70d 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -560,12 +560,12 @@ if (empty($reshook)) { if ($lines[$i]->id == $line_id) { - // delete single warehouse line - $line->id = $line_id; - if (! $error && $line->delete($user) < 0) - { - $error++; - } + // delete single warehouse line + $line->id = $line_id; + if (! $error && $line->delete($user) < 0) + { + $error++; + } } unset($_POST["lineid"]); } @@ -949,31 +949,28 @@ if ($action == 'create') print ''; - print '
    '; - print ''; - // Load receptions already done for same order $object->loadReceptions(); @@ -1113,59 +1110,57 @@ if ($action == 'create') $stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number $deliverableQty=$dispatchLines[$indiceAsked]['qty']; + // Quantity to send + print ''; - - // Quantity to send - print ''; - - // Stock - if (! empty($conf->stock->enabled)) + else { - print ''; + } + + if (!empty($conf->productbatch->enabled)) + { + if (!empty($product->status_batch)) + { + print ''; + print ''; + print ''; } - - if (!empty($conf->productbatch->enabled)) - { - if (!empty($product->status_batch)) - { - print ''; - print ''; - print ''; - } - else { - print ''; - } + else { + print ''; } - print "\n"; + } + print "\n"; } //Display lines extrafields diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index f5f605532b8..1a201a4bfd0 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -305,29 +305,28 @@ if (empty($reshook)) { $fk_parent_line = 0; } - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->qty, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - 'HT', - $product_type, - $i, - false, - 0, - null, - $lines[$i]->rowid, - 0, - $lines[$i]->ref_supplier - + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->qty, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + 'HT', + $product_type, + $i, + false, + 0, + null, + $lines[$i]->rowid, + 0, + $lines[$i]->ref_supplier ); $rcp->add_object_linked('facture_fourn_det', $result); @@ -533,9 +532,9 @@ if ($resql) } - $arrayofmassactions = array( -// 'presend'=>$langs->trans("SendByMail"), -); + $arrayofmassactions = array( + // 'presend'=>$langs->trans("SendByMail"), + ); if($user->rights->fournisseur->facture->creer)$arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisSupplier"); if($massaction == 'createbills') $arrayofmassactions=array(); diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 944e1f5e4f5..e4bae7558d1 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -42,38 +42,38 @@ $langs->load("receptions"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); $total=0; $ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> - - + + + if ($user->rights->reception->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> - 1) { diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 21ffa62bb8f..32edd342cb8 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -390,19 +390,20 @@ if ($id) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->salaries->write) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 56b92c42057..e7184764e7b 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -311,17 +311,17 @@ if ($action == 'sethideinactivethirdparty') } } if($action=='setonsearchandlistgooncustomerorsuppliercard'){ - $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); - $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); + if (! $res > 0) $error++; + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } /* diff --git a/htdocs/societe/canvas/company/tpl/card_create.tpl.php b/htdocs/societe/canvas/company/tpl/card_create.tpl.php index 0557f8608f9..80e0a23bdd6 100644 --- a/htdocs/societe/canvas/company/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_create.tpl.php @@ -32,15 +32,15 @@ if (empty($conf) || ! is_object($conf)) control->tpl['error']; ?> use_javascript_ajax) { ?> -control->tpl['ajax_selecttype']; ?> + control->tpl['ajax_selecttype']; ?>
    -trans("ThirdPartyType") ?>:   + trans("ThirdPartyType") ?>:   -trans("CompanyFoundation"); ?>     + trans("CompanyFoundation"); ?>     trans("Individual"); ?> (trans("ToCreateContactWithSameName") ?>)

    -control->tpl['ajax_selectcountry']; ?> + control->tpl['ajax_selectcountry']; ?> control->tpl['js_checkVatPopup']) echo $this->control->tpl['js_checkVatPopup']; ?> @@ -96,14 +96,15 @@ if (empty($conf) || ! is_object($conf)) -control->tpl['suppliercategory']) > 0) { ?> + control->tpl['suppliercategory']) > 0) { ?> - + barcode->enabled)) { ?> +if (! empty($conf->barcode->enabled)) { ?> diff --git a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php index f2de27c0ba1..11100c79d75 100644 --- a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php @@ -59,7 +59,7 @@ $contact = $GLOBALS['objcanvas']->control->object; - -barcode->enabled)) { ?> +if (! empty($conf->barcode->enabled)) { ?> @@ -209,9 +208,9 @@ for ($i=1; $i<=4; $i++) { - +control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?> +if(!empty($this->control->tpl['localtax'])) echo $this->control->tpl['localtax']; ?>
    '; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int'); + print ''; + print ''; + } + else print $langs->trans("NA"); + print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + // Stock + if (! empty($conf->stock->enabled)) + { + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? { - if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty=GETPOST('qtyl'.$indiceAsked, 'int'); - print ''; - print ''; + // Show warehouse combo list + $ent = "entl".$indiceAsked; + $idl = "idl".$indiceAsked; + $tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; + if ($line->fk_product > 0) + { + print ''; + print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1); + } } - else print $langs->trans("NA"); - print ''; - if ($line->product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? - { - // Show warehouse combo list - $ent = "entl".$indiceAsked; - $idl = "idl".$indiceAsked; - $tmpentrepot_id = is_numeric(GETPOST($ent, 'int'))?GETPOST($ent, 'int'):$warehouse_id; - if ($line->fk_product > 0) - { - print ''; - print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1); - } - } - else - { - print $langs->trans("Service"); - } + print $langs->trans("Service"); + } + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, ""); + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, ""); print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc' . $indiceAsked, '', '', 1, ""); - print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo' . $indiceAsked, '', '', 1, ""); - print '
    trans("Reception"); ?> - global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' getNomUrl(1); ?>date_delivery, 'day'); ?>date_delivery, 'day'); ?> rights->reception->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> getLibStatut(3); ?> - element != 'order_supplier') { - ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - element != 'order_supplier') { ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> +
    trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?>
    trans('Gencod'); ?> control->tpl['prefix_customercode'] || $this->control->tpl['prefix_suppliercode']) && $this->control->tpl['prefix_comm']) { ?> - control->tpl['prefix_comm']; ?> + control->tpl['prefix_comm']; ?> @@ -116,12 +116,11 @@ if ($this->control->tpl['fournisseur']) { trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?>
    trans('Gencod'); ?> trans("DefaultLang"); ?> control->tpl['select_lang']; ?>

    diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 69e7dc48171..9048b272995 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -25,10 +25,8 @@ if (empty($conf) || ! is_object($conf)) $soc = $GLOBALS['objcanvas']->control->object; -?> - -\n"; $head = societe_prepare_head($soc); diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index 54d09bf3c29..8493027bef7 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -32,15 +32,15 @@ if (empty($conf) || ! is_object($conf)) control->tpl['error']; ?> use_javascript_ajax) { ?> -control->tpl['ajax_selecttype']; ?> + control->tpl['ajax_selecttype']; ?>
    -trans("ThirdPartyType") ?>:   + trans("ThirdPartyType") ?>:   -trans("CompanyFoundation"); ?>     + trans("CompanyFoundation"); ?>     trans("Individual"); ?> (trans("ToCreateContactWithSameName") ?>)

    -control->tpl['ajax_selectcountry']; ?> + control->tpl['ajax_selectcountry']; ?>
    " method="POST" name="formsoc"> @@ -106,14 +106,15 @@ if (empty($conf) || ! is_object($conf)) -control->tpl['suppliercategory']) > 0) { ?> + control->tpl['suppliercategory']) > 0) { ?> trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?> - + barcode->enabled)) { ?> +if (! empty($conf->barcode->enabled)) { ?> trans('Gencod'); ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php index 487da67c593..6f3628d93b7 100644 --- a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php @@ -56,7 +56,7 @@ if (empty($conf) || ! is_object($conf)) control->tpl['prefix_customercode'] || $this->control->tpl['prefix_suppliercode']) && $this->control->tpl['prefix_comm']) { ?> - control->tpl['prefix_comm']; ?> + control->tpl['prefix_comm']; ?> @@ -113,7 +113,7 @@ if ($this->control->tpl['fournisseur']) { trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?> - diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index e7e122b9114..b1e5d052adc 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -25,19 +25,15 @@ if (empty($conf) || ! is_object($conf)) $object = $GLOBALS['objcanvas']->control->object; -?> - -\n"; $head = societe_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); -?> - -control->tpl['error']) echo $this->control->tpl['error']; ?> -control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> +if ($this->control->tpl['error']) echo $this->control->tpl['error']; +if ($this->control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> @@ -230,6 +226,5 @@ $result=show_contacts($conf, $langs, $db, $object); // Projects list $result=show_projects($conf, $langs, $db, $object); -?> - +print "\n"; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e51ceca9c37..0d447ebe6c3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -609,11 +609,11 @@ if (empty($reshook)) { 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; + $errors[] = "ErrorFileSizeTooLarge"; + break; case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; + $errors[] = "ErrorFilePartiallyUploaded"; + break; } } // Gestion du logo de la société @@ -774,11 +774,11 @@ if (empty($reshook)) { 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; + $errors[] = "ErrorFileSizeTooLarge"; + break; case 3: //uploaded file was only partially uploaded - $errors[] = "ErrorFilePartiallyUploaded"; - break; + $errors[] = "ErrorFilePartiallyUploaded"; + break; } } // Gestion du logo de la société @@ -1896,7 +1896,7 @@ else print ''; } else - { + { print $object->code_fournisseur; print ''; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 1ed4916e3c9..91825fa0d2b 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -850,6 +850,46 @@ class Thirdparties extends DolibarrApi return $result; } + /** + * Get representatives of thirdparty + * + * @param int $id ID of the thirdparty + * @param string $mode 0=Array with properties, 1=Array of id. + * + * @url GET {id}/representatives + * + * @return array List of representatives of thirdparty + * + * @throws 400 + * @throws 401 + * @throws 404 + */ + public function getSalesRepresentatives($id, $mode = 0) + { + $obj_ret = array(); + + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } + + if(empty($id)) { + throw new RestException(400, 'Thirdparty ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('societe', $id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->company->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } + + $result = $this->company->getSalesRepresentatives(DolibarrApiAccess::$user, $mode); + + return $result; + } + /** * Get fixed amount discount of a thirdparty (all sources: deposit, credit note, commercial offers...) * @@ -1060,12 +1100,13 @@ class Thirdparties extends DolibarrApi $returnAccounts = array(); - foreach($accounts as $account){ - $object= array(); - foreach($account as $key => $value) - if(in_array($key, $fields)){ + foreach ($accounts as $account) { + $object = array(); + foreach ($account as $key => $value) { + if (in_array($key, $fields)) { $object[$key] = $value; } + } $returnAccounts[] = $object; } @@ -1264,7 +1305,7 @@ class Thirdparties extends DolibarrApi } } - /** + /** * Get a specific gateway attached to a thirdparty (by specifying the site key) * * @param int $id ID of thirdparty @@ -1321,12 +1362,13 @@ class Thirdparties extends DolibarrApi $returnAccounts = array(); - foreach($accounts as $account){ - $object= array(); - foreach($account as $key => $value) - if(in_array($key, $fields)){ + foreach ($accounts as $account) { + $object = array(); + foreach ($account as $key => $value) { + if(in_array($key, $fields)) { $object[$key] = $value; } + } $returnAccounts[] = $object; } @@ -1439,16 +1481,18 @@ class Thirdparties extends DolibarrApi $account->fk_soc = $id; $account->site = $site; - if ($account->create(DolibarrApiAccess::$user) < 0) + if ($account->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error creating SocieteAccount entity.'); - // We found an existing SocieteAccount entity, we are replacing it + } + // We found an existing SocieteAccount entity, we are replacing it } else { - if(isset($request_data['site']) && $request_data['site'] !== $site) { + if (isset($request_data['site']) && $request_data['site'] !== $site) { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '". $request_data['site']."' "; $result = $db->query($sql); - if($result->num_rows !== 0) + if ($result->num_rows !== 0) { throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) from $site to ".$request_data['site'] . " but another SocieteAccount entity already exists with this site key."); + } } $obj = $db->fetch_object($result); @@ -1664,12 +1708,12 @@ class Thirdparties extends DolibarrApi return $thirdparty; } - /** - * Fetch properties of a thirdparty object. - * - * Return an array with thirdparty informations - * - * @param int $rowid Id of third party to load + /** + * Fetch properties of a thirdparty object. + * + * Return an array with thirdparty informations + * + * @param int $rowid Id of third party to load * @param string $ref Reference of third party, name (Warning, this can return several records) * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr) * @param string $ref_int Internal reference of third party (not used by dolibarr) @@ -1681,38 +1725,38 @@ class Thirdparties extends DolibarrApi * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) * @param string $email Email of third party (Warning, this can return several records) * @param string $ref_alias Name_alias of third party (Warning, this can return several records) - * @return array|mixed data without useless information - * - * @throws RestException - */ - private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') - { - if(! DolibarrApiAccess::$user->rights->societe->lire) { - throw new RestException(401); - } + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '') + { + if(! DolibarrApiAccess::$user->rights->societe->lire) { + throw new RestException(401); + } - $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); - if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); - } + $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias); + if( ! $result ) { + throw new RestException(404, 'Thirdparty not found'); + } - if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; - } + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } else { + $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; + } - $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote); - $this->company->absolute_discount = price2num($absolute_discount, 'MT'); - $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT'); + $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote); + $this->company->absolute_discount = price2num($absolute_discount, 'MT'); + $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT'); - return $this->_cleanObjectDatas($this->company); - } + return $this->_cleanObjectDatas($this->company); + } } diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php index 45f11c5a4ce..d403499a79e 100644 --- a/htdocs/societe/class/companybankaccount.class.php +++ b/htdocs/societe/class/companybankaccount.class.php @@ -20,9 +20,9 @@ */ /** - * \file htdocs/societe/class/companybankaccount.class.php - * \ingroup societe - * \brief File of class to manage bank accounts description of third parties + * \file htdocs/societe/class/companybankaccount.class.php + * \ingroup societe + * \brief File of class to manage bank accounts description of third parties */ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; @@ -174,27 +174,27 @@ class CompanyBankAccount extends Account $result = $this->db->query($sql); if ($result) { - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('COMPANY_RIB_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers - if(! $error ) + if (! $notrigger) { - return 1; + // Call trigger + $result=$this->call_trigger('COMPANY_RIB_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + if(! $error ) + { + return 1; + } + else + { + return -1; + } } else { - return -1; + return 1; } } else - { - return 1; - } - } - else { dol_print_error($this->db); return -1; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 36d33c6e221..edea020ec3a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1228,7 +1228,7 @@ class Societe extends CommonObject } } else - { + { $this->db->rollback(); dol_syslog(get_class($this)."::Update fails verify ".join(',', $this->errors), LOG_WARNING); return -3; @@ -1867,7 +1867,7 @@ class Societe extends CommonObject $reparray=array(); - $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; + $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.office_phone, u.job, u.email, u.statut, u.entity, u.photo"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { @@ -1896,6 +1896,8 @@ class Societe extends CommonObject $reparray[$i]['lastname']=$obj->lastname; $reparray[$i]['firstname']=$obj->firstname; $reparray[$i]['email']=$obj->email; + $reparray[$i]['phone']=$obj->office_phone; + $reparray[$i]['job']=$obj->job; $reparray[$i]['statut']=$obj->statut; $reparray[$i]['entity']=$obj->entity; $reparray[$i]['login']=$obj->login; @@ -2128,8 +2130,8 @@ class Societe extends CommonObject if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') { - $label.= '' . $langs->trans("ShowCustomer") . ''; - $linkstart = ''; + $linkstart = 'id; + $sql.= " ORDER BY lastname, firstname"; $resql=$this->db->query($sql); if ($resql) @@ -3067,8 +3070,8 @@ class Societe extends CommonObject //Check NIF if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) - return 1; - else + return 1; + else return -1; //algorithm checking type code CIF @@ -3080,29 +3083,29 @@ class Societe extends CommonObject //Chek special NIF if (preg_match('/^[KLM]{1}/', $string)) if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) - return 1; - else + return 1; + else return -1; //Check CIF if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) - return 2; - else + return 2; + else return -2; //Check NIE T if (preg_match('/^[T]{1}/', $string)) if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) - return 3; - else + return 3; + else return -3; //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) - return 3; - else + return 3; + else return -3; //Can not be verified diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c6373674e4c..ad793fcf63e 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -234,7 +234,7 @@ if ($action=="change") // Change customer for TakePOS // @TODO Check if draft invoice already exists, if not create it or return a warning to ask to enter at least one line to have it created automatically $sql="UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); - ?> + ?> - '; if ($companystatic->fk_parent > 0) { - $companyparent->fetch($companystatic->fk_parent); - print $companyparent->getNomUrl(1); + $companyparent->fetch($companystatic->fk_parent); + print $companyparent->getNomUrl(1); } print ""; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 6cb1b4abbbe..df803b180ab 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -564,13 +564,13 @@ if (empty($reshook)) $db->begin(); - if (empty($newcu)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; - } else { - $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; - $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; - $sql.= " WHERE site = 'stripe' 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 fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + } else { + $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; + $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; + $sql.= " WHERE site = 'stripe' 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); @@ -609,37 +609,33 @@ if (empty($reshook)) $db->begin(); - if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE 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 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'); - } + if (empty($newsup)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE 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 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'); } + } $resql = $db->query($sql); $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 ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; - } - 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)."')"; + } catch(Exception $e) { $error++; setEventMessages($e->getMessage(), null, 'errors'); } @@ -700,23 +696,25 @@ if (empty($reshook)) { try { if (preg_match('/pm_/', $source)) - { - $payment_method = \Stripe\PaymentMethod::retrieve($source, array("stripe_account" => $stripeacc)); - if ($payment_method) - { - $payment_method->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(); - } + $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; @@ -1296,54 +1294,60 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' } print "
    "; print "
    "; - print '
    '; + print '
    '; } // List of Stripe payment modes if (! empty($conf->stripe->enabled) && ! empty($conf->stripeconnect->enabled) && $object->fournisseur && ! empty($stripesupplieracc)) { - print load_fiche_titre($langs->trans('StripeBalance').($stripesupplieracc?' (Stripe connection with StripeConnect account '.$stripesupplieracc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); - $balance = \Stripe\Balance::retrieve(array("stripe_account" => $stripesupplieracc)); + 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 ''; + print ''; + print ''; - $currencybalance = array(); + $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; - else $currencybalance[$cpt->currency]->available=$cpt->amount; - $currencybalance[$cpt->currency]->currency=$cpt->currency; + $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; + } + $currencybalance[$cpt->currency]->currency=$cpt->currency; } } - if (is_array($balance->pending) && count($balance->pending)) + if (is_array($balance->pending) && count($balance->pending)) { foreach ($balance->pending 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]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; - else $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + $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]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount / 100; + } else { + $currencybalance[$cpt->currency]->pending=$currencybalance[$cpt->currency]->available+$cpt->amount; + } } - } + } if (is_array($currencybalance)) { foreach ($currencybalance as $cpt) { - print ''; + print ''; } } - print '
    '.$langs->trans('Currency').''.$langs->trans('Available').''.$langs->trans('Pending').''.$langs->trans('Total').'
    '.$langs->trans('Total').'
    '.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
    '.$langs->trans("Currency".strtoupper($cpt->currency)).''.price($cpt->available, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).''.price($cpt->available+$cpt->pending, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).'
    '; - print '
    '; + print ''; + print '
    '; } // List of bank accounts @@ -1394,12 +1398,13 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $string .= $rib->code_guichet.' '; } 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) { if (! checkBanForAccount($rib)) { diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 8bb112fa998..9a17ac1e202 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -42,6 +42,8 @@ if ($nbofsalesrepresentative > 0) $userstatic->statut=$val['statut']; $userstatic->photo=$val['photo']; $userstatic->email=$val['email']; + $userstatic->phone=$val['phone']; + $userstatic->job=$val['job']; $userstatic->entity=$val['entity']; print $userstatic->getNomUrl(-1); print ' '; diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 05d8937f293..e101a40ffbf 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -177,12 +177,12 @@ print "\n"; print ''; print ''; print $langs->trans("StripeLiveEnabled").''; - if ($conf->use_javascript_ajax) { +if ($conf->use_javascript_ajax) { print ajax_constantonoff('STRIPE_LIVE'); - } else { +} else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); print $form->selectarray("STRIPE_LIVE", $arrval, $conf->global->STRIPE_LIVE); - } +} print ''; if (empty($conf->stripeconnect->enabled)) @@ -203,7 +203,7 @@ if (empty($conf->stripeconnect->enabled)) print ''.$langs->trans("STRIPE_TEST_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; - print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
    '; + print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
    '; } print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; @@ -239,7 +239,7 @@ if (empty($conf->stripeconnect->enabled)) print '
    '; print img_picto($langs->trans("Disabled"), 'switch_off'); } - //print $endpoint; + //print $endpoint; } else { @@ -275,8 +275,8 @@ if (empty($conf->stripeconnect->enabled)) print ''; print ''.$langs->trans("STRIPE_LIVE_WEBHOOK_KEY").''; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; - print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
    '; + print ''; + print '   '.$langs->trans("Example").': we_xxxxxxxxxxxxxxxxxxxxxxxx
    '; } print ''; print '   '.$langs->trans("Example").': whsec_xxxxxxxxxxxxxxxxxxxxxxxx'; @@ -312,7 +312,7 @@ if (empty($conf->stripeconnect->enabled)) print '
    '; print img_picto($langs->trans("Disabled"), 'switch_off'); } - //print $endpoint; + //print $endpoint; } else { @@ -366,14 +366,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // What is this for ? // Activate Payment Request API if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code { - print ''; + print ''; print $langs->trans("STRIPE_PAYMENT_REQUEST_API").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_PAYMENT_REQUEST_API'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_PAYMENT_REQUEST_API", $arrval, $conf->global->STRIPE_PAYMENT_REQUEST_API); + } print ''; } @@ -382,12 +382,12 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code { print ''; print $langs->trans("STRIPE_SEPA_DIRECT_DEBIT").''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); - } + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_SEPA_DIRECT_DEBIT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_SEPA_DIRECT_DEBIT", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); + } print ''; } diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 99abc1fd510..a9e417aa581 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018 Thibault FOUCART + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,29 +122,28 @@ if (!$rowid) //print $list; foreach ($list->data as $charge) { - if ($charge->refunded=='1'){ + if ($charge->refunded=='1') { $status = img_picto($langs->trans("refunded"), 'statut6'); - } elseif ($charge->paid=='1'){ - $status = img_picto($langs->trans("".$charge->status.""), 'statut4'); - } else { + } elseif ($charge->paid=='1') { + $status = img_picto($langs->trans("".$charge->status.""), 'statut4'); + } else { $label="Message: ".$charge->failure_message."
    "; $label.="Réseau: ".$charge->outcome->network_status."
    "; $label.="Statut: ".$langs->trans("".$charge->outcome->seller_message.""); $status = $form->textwithpicto(img_picto($langs->trans("".$charge->status.""), 'statut8'), $label, 1); - } + } - if ($charge->payment_method_details->type=='card') - { + if ($charge->payment_method_details->type=='card') { $type = $langs->trans("card"); - } elseif ($charge->source->type=='card'){ + } elseif ($charge->source->type=='card'){ $type = $langs->trans("card"); - } elseif ($charge->payment_method_details->type=='three_d_secure'){ + } elseif ($charge->payment_method_details->type=='three_d_secure'){ $type = $langs->trans("card3DS"); - } + } - if (! empty($charge->payment_intent)) { - $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent); - } + if (! empty($charge->payment_intent)) { + $charge = \Stripe\PaymentIntent::retrieve($charge->payment_intent); + } // The metadata FULLTAG is defined by the online payment page $FULLTAG=$charge->metadata->FULLTAG; @@ -211,19 +211,25 @@ if (!$rowid) print "\n"; // Origine print ""; - if ($charge->metadata->dol_type=="order"){ + if ($charge->metadata->dol_type=="order") { $object = new Commande($db); $object->fetch($charge->metadata->dol_id); - if ($object->id > 0) { - print "
    ".img_picto('', 'object_order')." ".$object->ref.""; - } else print $FULLTAG; - } elseif ($charge->metadata->dol_type=="invoice"){ + if ($object->id > 0) { + print "".img_picto('', 'object_order')." ".$object->ref.""; + } else { + print $FULLTAG; + } + } elseif ($charge->metadata->dol_type=="invoice") { $object = new Facture($db); $object->fetch($charge->metadata->dol_id); - if ($object->id > 0) { - print "".img_picto('', 'object_invoice')." ".$object->ref.""; - } else print $FULLTAG; - } else print $FULLTAG; + if ($object->id > 0) { + print "".img_picto('', 'object_invoice')." ".$object->ref.""; + } else { + print $FULLTAG; + } + } else { + print $FULLTAG; + } print "\n"; // Date payment print ''.dol_print_date($charge->created, '%d/%m/%Y %H:%M')."\n"; diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 593447919a7..021a9fac1f9 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -62,6 +62,9 @@ class Stripe extends CommonObject public $code; public $declinecode; + /** + * @var string Message + */ public $message; /** @@ -338,8 +341,11 @@ class Stripe extends CommonObject } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL; } - if (! in_array($currency_code, $arrayzerounitcurrency)) $stripefee = round($fee * 100); - else $stripefee = round($fee); + if (! in_array($currency_code, $arrayzerounitcurrency)) { + $stripefee = round($fee * 100); + } else { + $stripefee = round($fee); + } $paymentintent = null; diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 45af7923fca..2614c8498f3 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -186,12 +186,12 @@ if (empty($reshook)) } } - // Check parameters -// if (! GETPOST('paiementcode')) -// { -// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors'); -// $error++; -// } + // Check parameters + /*if (! GETPOST('paiementcode')) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('PaymentMode')), null, 'errors'); + $error++; + }*/ if (! empty($conf->banque->enabled)) { @@ -209,11 +209,11 @@ if (empty($reshook)) $error++; } -// if (empty($datepaye)) -// { -// setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); -// $error++; -// } + /*if (empty($datepaye)) + { + setEventMessages($langs->transnoentities('ErrorFieldRequired',$langs->transnoentities('Date')), null, 'errors'); + $error++; + }*/ // Check if payments in both currency if ($totalpayment > 0 && $multicurrency_totalpayment > 0) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 3bbd8d8a33f..b953087b885 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -319,78 +319,92 @@ if (empty($reshook)) $id = $object->create($user); if ($id > 0) { - dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); + dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); - $classname = ucfirst($subelement); - $srcobject = new $classname($db); + $classname = ucfirst($subelement); + $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); - $result = $srcobject->fetch($object->origin_id); + dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); + $result = $srcobject->fetch($object->origin_id); - if ($result > 0) + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + $srcobject->fetch_lines(); $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; + } + + $fk_parent_line=0; + $num=count($lines); + for ($i=0;$i<$num;$i++) + { + $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); + $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); + + // Positive line + $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); + + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + $fk_parent_line = 0; } - $fk_parent_line=0; - $num=count($lines); - for ($i=0;$i<$num;$i++) - { - $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); - $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - - // Positive line - $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); - - // Reset fk_parent_line for no child products and special product - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { - $fk_parent_line = 0; - } - - // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals(); - $array_options = $lines[$i]->array_options; - } - - $result = $object->addline( - $desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, $lines[$i]->remise_percent, - 'HT', 0, $lines[$i]->info_bits, $product_type, - $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, - $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, - $lines[$i]->ref_supplier, $lines[$i]->fk_unit - ); - - if ($result > 0) { - $lineid = $result; - } else { - $lineid = 0; - $error ++; - break; - } - - // Defined the new fk_parent_line - if ($result > 0 && $lines[$i]->product_type == 9) { - $fk_parent_line = $result; - } + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + $lines[$i]->fetch_optionals(); + $array_options = $lines[$i]->array_options; } - // Hooks - $parameters = array('objFrom' => $srcobject); - $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if ($reshook < 0) + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + 'HT', + 0, + $lines[$i]->info_bits, + $product_type, + $lines[$i]->rang, + $lines[$i]->special_code, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, $label, + $array_options, + $lines[$i]->ref_supplier, + $lines[$i]->fk_unit + ); + + if ($result > 0) { + $lineid = $result; + } else { + $lineid = 0; $error ++; - } else { - setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + break; + } + + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) { + $fk_parent_line = $result; + } + } + + // Hooks + $parameters = array('objFrom' => $srcobject); + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if ($reshook < 0) { $error ++; } + } else { + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); + $error ++; + } } else { setEventMessages($object->error, $object->errors, 'errors'); $error ++; @@ -736,64 +750,64 @@ if (empty($reshook)) if (! $error && $result > 0) { - $db->commit(); + $db->commit(); - $ret=$object->fetch($object->id); // Reload to get new records + $ret=$object->fetch($object->id); // Reload to get new records - // Define output language - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model=$object->modelpdf; - $ret = $object->fetch($id); // Reload to get new records - - $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) dol_print_error($db, $result); + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); } + $model=$object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records - unset($_POST['prod_entry_mode']); + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) dol_print_error($db, $result); + } - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['remise_percent']); - unset($_POST['pu']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['label']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - unset($localtax1_tx); - unset($localtax2_tx); - unset($_POST['np_marginRate']); - unset($_POST['np_markRate']); - unset($_POST['dp_desc']); - unset($_POST['idprodfournprice']); - unset($_POST['idprod']); + unset($_POST['prod_entry_mode']); - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['remise_percent']); + unset($_POST['pu']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['label']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + unset($localtax1_tx); + unset($localtax2_tx); + unset($_POST['np_marginRate']); + unset($_POST['np_markRate']); + unset($_POST['dp_desc']); + unset($_POST['idprodfournprice']); + unset($_POST['idprod']); + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); } else { @@ -801,7 +815,6 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - //} } } @@ -1452,19 +1465,20 @@ if ($action == 'create') $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:-1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e4e0eb0b11c..be272ee2d36 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1739,16 +1739,15 @@ class SupplierProposal extends CommonObject if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("", $conf); - $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } // Call trigger diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index 69c6f0d193e..d60fb3c04bc 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -158,20 +158,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($permissiontoedit) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 7c5d533a401..991059b9141 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -113,20 +113,21 @@ if ($object->id > 0) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index e34ba2cd06c..ec269354af6 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -78,20 +78,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index b827117d7c5..447dc057979 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -98,20 +98,21 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->supplier_proposal->creer) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index 05cf99f3170..c87bb46adf3 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -24,39 +24,38 @@ if (empty($conf) || ! is_object($conf)) exit; } -?> - +print "\n"; - $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("SupplierProposal"); ?> trans("ShowSupplierProposal"), "supplier_proposal").' '.$objectlink->ref; ?> datec, 'day'); ?> rights->supplier_proposal->lire) { - $total = $total + $objectlink->total_ht; - echo price($objectlink->total_ht); - } ?> + if ($user->rights->supplier_proposal->lire) { + $total = $total + $objectlink->total_ht; + echo price($objectlink->total_ht); + } ?> getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - 1) { @@ -72,6 +71,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 6289f382273..a1f07f4f7ad 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -79,7 +79,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity); - $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if ($conf->global->TAKEPOS_ORDER_NOTES==1) { @@ -247,15 +247,15 @@ $formmail = new FormMail($db); $nboftemplates = $formmail->fetchAllEMailTemplate('facture_send', $user, null, -1); // We set lang=null to get in priority record with no lang //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); $arrayofmessagename=array(); -if (is_array($formmail->lines_model)) -{ - foreach($formmail->lines_model as $modelmail) - { - //var_dump($modelmail); - $moreonlabel=''; - if (! empty($arrayofmessagename[$modelmail->label])) $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; - $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; - } +if (is_array($formmail->lines_model)) { + foreach($formmail->lines_model as $modelmail) { + //var_dump($modelmail); + $moreonlabel=''; + if (! empty($arrayofmessagename[$modelmail->label])) { + $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; + } + $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; + } } //var_dump($arraydefaultmessage); //var_dump($arrayofmessagename); diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index b34889a3dce..b009d01659b 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -166,12 +166,12 @@ if (! empty($conf->stock->enabled)) print ''.$langs->trans("CashDeskDoNotDecreaseStock").''; // Force warehouse (this is not a default value) print ''; if (empty($conf->productbatch->enabled)) { - print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1); + print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1); } else { if (!$conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}) { - $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminal, 1, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminal, 1, 'chaine', 0, '', $conf->entity); } print $langs->trans("Yes").'
    '; print ''.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').''; diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 74e83ffbef3..cd45d0c1792 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -157,8 +157,7 @@ $( document ).ready(function() { $('#'+val.label).draggable().bind('click', function(){ $(this).focus(); }) - + $('body').append('
    '+val.label+'
    '); }); @@ -168,13 +167,13 @@ $( document ).ready(function() { -admin){?> +admin) {?> diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 349c03540b2..aea8d14ebba 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -223,7 +223,7 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'LIQ') $paycode = 'cash'; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; -?> + ?> @@ -236,11 +236,11 @@ $numpad=$conf->global->TAKEPOS_NUMPAD; if ($paycode == 'LIQ') $paycode = 'cash'; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; -?> + ?> + $button = array_pop($action_buttons); + ?> @@ -251,12 +251,11 @@ $button = array_pop($action_buttons); if ($paycode == 'LIQ') $paycode = 'cash'; if ($paycode == 'CB') $paycode = 'card'; if ($paycode == 'CHQ') $paycode = 'cheque'; -?> + ?> - - + @@ -265,17 +264,17 @@ $button = array_pop($action_buttons); + ?> - + ?> -
    diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 38ad9103ab9..bdf38c2bafe 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -100,7 +100,8 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) trans('Date')." ".dol_print_date($object->date, 'day').'
    '; if ($conf->global->TAKEPOS_CUSTOM_RECEIPT) print $conf->global->TAKEPOS_RECEIPT_NAME." "; -print $object->ref; +if ($object->statut == Facture::STATUS_DRAFT) print str_replace(")", "", str_replace("-", " ".$langs->trans('Place')." ", str_replace("(PROV-POS", $langs->trans("Terminal")." ", $object->ref))); +else print $object->ref; if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOMER) { $soc = new Societe($db); @@ -130,16 +131,17 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME lines as $line) { - ?> + ?> - product_label)) echo $line->product_label; - else echo $line->description;?> + + product_label)) echo $line->product_label; + else echo $line->description;?> qty;?> total_ttc/$line->qty;?> total_ttc);?> - @@ -150,30 +152,28 @@ if ($conf->global->TAKEPOS_CUSTOM_RECEIPT && $conf->global->TAKEPOS_SHOW_CUSTOME trans("TotalHT");?> total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n";?> -global->TAKEPOS_TICKET_VAT_GROUPPED):?> -global->TAKEPOS_TICKET_VAT_GROUPPED) { $vat_groups = array(); foreach ($object->lines as $line) { - if(!array_key_exists($line->tva_tx, $vat_groups)){ + if(!array_key_exists($line->tva_tx, $vat_groups)) { $vat_groups[$line->tva_tx] = 0; } $vat_groups[$line->tva_tx] += $line->total_tva; } - foreach($vat_groups as $key => $val){ - ?> + foreach($vat_groups as $key => $val) { + ?> trans("VAT").' '.vatrate($key, 1);?> currency)."\n";?> - - +} else { ?> trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n";?> - + trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n";?> diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index d3a0f466fc8..dd65469ec05 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -747,7 +747,7 @@ $menus[$r++]=array('title'=>'< print ' '; print ''.img_picto('', 'searchclear').''; print ''; -?> + ?> @@ -759,7 +759,7 @@ $menus[$r++]=array('title'=>'< $count=0; while ($count < $MAXCATEG) { - ?> + ?>
    id="catdiv"> '<
    +
    - @@ -794,7 +794,7 @@ $menus[$r++]=array('title'=>'< $count=0; while ($count < $MAXPRODUCT) { - ?> + ?>
    onclick="MoreProducts('less');" onclick="MoreProducts('more');" > '<
    +
    - diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 09e89c98b71..28029def9ff 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -555,7 +555,7 @@ div.divsearchfield { browser->layout == 'phone') { -?> + ?> .divsearchfieldfilter { white-space: nowrap; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 46e1993c1b6..04ae5d298c4 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1230,11 +1230,12 @@ td.showDragHandle { display: block; font-family: "RobotoDraft","Roboto",sans-serif; left: 0; -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + } else { ?> position: fixed; top: 50px; - + z-index: 90; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); @@ -1259,12 +1260,14 @@ td.showDragHandle { -moz-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); -webkit-overflow-scrolling: touch; -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + } else { ?> overflow-x: hidden; overflow-y: auto; - - + } /* @@ -1315,11 +1318,12 @@ div.login_block { } .side-nav { -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> - + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + } else { ?> overflow-x: initial !important; overflow-y: scroll; - + display: block; position: relative; @@ -1363,11 +1367,12 @@ div.login_block { z-index: 91; background: rgb(); border-right: 1px solid rgba(0,0,0,0.3); -browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> + browser->layout, array('phone','tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?> top: 50px ! important; - + top: 60px ! important; - + } div.fiche { margin-: 6px !important; @@ -1730,12 +1735,12 @@ li.tmenu, li.tmenusel { vertical-align: bottom; global->MAIN_MENU_INVERT)) { ?> float: ; - + height: px; padding: 0px 0px 2px 0px; - + padding: 0px 0px 0px 0px; - + position:relative; display: block; margin: 0px 0px 0px 0px; @@ -1756,9 +1761,9 @@ div.tmenuleft margin-top: 0px; dol_optimize_smallscreen)) { ?> width: 5px; - + height: px; - + } div.tmenucenter @@ -1887,82 +1892,82 @@ div.mainmenu.website { background-image: url(); } -'name of class for div') + 'name of class for div') -$moduletomainmenu=array( - 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', - 'produit'=>'products','service'=>'products','stock'=>'products', - 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', - 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', - 'fournisseur'=>'companies', - 'barcode'=>'','fckeditor'=>'','categorie'=>'', -); -$mainmenuused='home'; -foreach($conf->modules as $val) -{ - $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); -} -$mainmenuusedarray=array_unique(explode(',', $mainmenuused)); - -$generic=1; -// Put here list of menu entries when the div.mainmenu.menuentry was previously defined -$divalreadydefined=array('home','companies','products','mrp','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); -// Put here list of menu entries we are sure we don't want -$divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); -foreach($mainmenuusedarray as $val) -{ - if (empty($val) || in_array($val, $divalreadydefined)) continue; - if (in_array($val, $divnotrequired)) continue; - //print "XXX".$val; - - // Search img file in module dir - $found=0; $url=''; - foreach($conf->file->dol_document_root as $dirroot) + $moduletomainmenu=array( + 'user'=>'','syslog'=>'','societe'=>'companies','projet'=>'project','propale'=>'commercial','commande'=>'commercial', + 'produit'=>'products','service'=>'products','stock'=>'products', + 'don'=>'accountancy','tax'=>'accountancy','banque'=>'accountancy','facture'=>'accountancy','compta'=>'accountancy','accounting'=>'accountancy','adherent'=>'members','import'=>'tools','export'=>'tools','mailing'=>'tools', + 'contrat'=>'commercial','ficheinter'=>'commercial','ticket'=>'ticket','deplacement'=>'commercial', + 'fournisseur'=>'companies', + 'barcode'=>'', + 'fckeditor'=>'', + 'categorie'=>'', + ); + $mainmenuused='home'; + foreach($conf->modules as $val) { - if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) - { - $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); - $found=1; - break; - } - elseif (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + $mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val); + } + $mainmenuusedarray=array_unique(explode(',', $mainmenuused)); + + $generic=1; + // Put here list of menu entries when the div.mainmenu.menuentry was previously defined + $divalreadydefined=array('home','companies','products','mrp','commercial','externalsite','accountancy','project','tools','members','agenda','ftp','holiday','hrm','bookmark','cashdesk','takepos','ecm','geoipmaxmind','gravatar','clicktodial','paypal','stripe','webservices','website'); + // Put here list of menu entries we are sure we don't want + $divnotrequired=array('multicurrency','salaries','ticket','margin','opensurvey','paybox','expensereport','incoterm','prelevement','propal','workflow','notification','supplier_proposal','cron','product','productbatch','expedition'); + foreach($mainmenuusedarray as $val) + { + if (empty($val) || in_array($val, $divalreadydefined)) continue; + if (in_array($val, $divnotrequired)) continue; + //print "XXX".$val; + + // Search img file in module dir + $found=0; $url=''; + foreach($conf->file->dol_document_root as $dirroot) { - $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); - $found=1; - break; + if (file_exists($dirroot."/".$val."/img/".$val."_over.png")) + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'_over.png', 1); + $found=1; + break; + } + elseif (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); + $found=1; + break; + } + } + // Img file not found + if (! $found) + { + if (! defined('DISABLE_FONT_AWSOME')) { + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + print 'div.mainmenu.'.$val.'::before { + content: "\f249"; + }'; + } + else + { + print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; + $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); + print "div.mainmenu.".$val." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; + } + $generic++; + } + else + { + print "div.mainmenu.".$val." {\n"; + print " background-image: url(".$url.");\n"; + print "}\n"; } } - // Img file not found - if (! $found) - { - if (! defined('DISABLE_FONT_AWSOME')) { - print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - print 'div.mainmenu.'.$val.'::before { - content: "\f249"; - }'; - } - else - { - print "/* A mainmenu entry was found but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n"; - $url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.(min($generic, 4))."_over.png", 1); - print "div.mainmenu.".$val." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; - } - $generic++; - } - else - { - print "div.mainmenu.".$val." {\n"; - print " background-image: url(".$url.");\n"; - print "}\n"; - } -} -// End of part to add more div class css -?> - - + // End of part to add more div class css +} // End test if $dol_hide_topmenu ?> .tmenuimage { padding:0 0 0 0 !important; diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index 9ee8363dc46..dee2168136c 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -190,20 +190,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
    '.$langs->trans('Project'); if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index a4c71476269..4289fab99dc 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -148,9 +148,9 @@ class Tickets extends DolibarrApi // String for user assigned if ($this->ticket->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($this->ticket->fk_user_assign); - $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + $userStatic = new User($this->db); + $userStatic->fetch($this->ticket->fk_user_assign); + $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; } // Messages of ticket @@ -296,9 +296,9 @@ class Tickets extends DolibarrApi $ticket_static = new Ticket($db); if ($ticket_static->fetch($obj->rowid)) { if ($ticket_static->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($ticket_static->fk_user_assign); - $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + $userStatic = new User($this->db); + $userStatic->fetch($ticket_static->fk_user_assign); + $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; } $obj_ret[] = $this->_cleanObjectDatas($ticket_static); } diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 42a319c3720..65682fef2b3 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -181,20 +181,21 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index c1cbaa26902..a80d455e43f 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -146,20 +146,21 @@ if ($object->id) $morehtmlref.='
    '.$langs->trans('Project') . ' '; if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + $morehtmlref.=' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index e2a9038ee62..be29b1be25e 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -210,6 +210,7 @@ $stringtoshow .= ''; print ''; print ''; @@ -257,6 +258,7 @@ if (! empty($dataseries) && count($dataseries) > 1) { print ''; print '
    ' . $langs->trans("Statistics") . ' ' . img_picto('', 'filter.png', 'id="idsubimgDOLUSERCOOKIE_ticket_by_status" class="linkobject"') . '
    '; +print ''; // Build graphic number of object $data = $stats->getNbByMonth($endyear, $startyear); diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index d5bda4297ca..7b4341cf684 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -189,20 +189,21 @@ if (! empty($conf->projet->enabled)) $morehtmlref.='
    '.$langs->trans('Project'); if ($user->rights->ticket->write) { - if ($action != 'classify') + if ($action != 'classify') { //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
    '; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
    '; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index 439feb121f8..538519bbf2e 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -21,11 +21,9 @@ if (empty($conf) || ! is_object($conf)) print "Error, template page can't be called as URL"; exit; } -?> - +print "\n"; -load('ticket'); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'datec', 'desc', 0, 0, 1); -$total=0; $ilink=0; +$total=0; +$ilink=0; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; -?> + ?> trans("Ticket"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' @@ -70,7 +69,7 @@ foreach($linkedObjectBlock as $key => $objectlink) ?> - 1) { @@ -86,6 +85,5 @@ if (count($linkedObjectBlock) > 1) - +print "\n"; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 9549fbe2ef1..778823d3d7d 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -72,7 +72,7 @@ class Users extends DolibarrApi $obj_ret = array(); if(! DolibarrApiAccess::$user->rights->user->user->lire) { - throw new RestException(401, "You are not allowed to read list of users"); + throw new RestException(401, "You are not allowed to read list of users"); } // case of external user, $societe param is ignored and replaced by user's socid @@ -226,10 +226,10 @@ class Users extends DolibarrApi if ($field == 'statut') { $result = $this->useraccount->setstatus($value); if ($result < 0) { - throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); + throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); } } else { - $this->useraccount->$field = $value; + $this->useraccount->$field = $value; } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 683d7291525..63abb02fd2e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2327,9 +2327,10 @@ class User extends CommonObject $label.= '
    '; $label.= '' . $langs->trans("User") . '
    '; $label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs, ''); - if (! empty($this->login)) - $label.= '
    ' . $langs->trans('Login') . ': ' . $this->login; - $label.= '
    ' . $langs->trans("EMail").': '.$this->email; + if (! empty($this->login)) $label.= '
    ' . $langs->trans('Login') . ': ' . $this->login; + if (! empty($this->job)) $label.= '
    ' . $langs->trans("Job").': '.$this->job; + $label.= '
    ' . $langs->trans("Email").': '.$this->email; + if (! empty($this->phone)) $label.= '
    ' . $langs->trans("Phone").': '.$this->phone; if (! empty($this->admin)) $label.= '
    ' . $langs->trans("Administrator").': '.yn($this->admin); if (! empty($this->socid) ) // Add thirdparty for external users diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 79b285bc114..04a0f4c3883 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -110,7 +110,7 @@ if ($id > 0) // Edit mode if ($action == 'edit') { - print ''; + print '
    '; if ($user->admin) { diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 8952b32f30b..a89fe447aa0 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -4,6 +4,7 @@ * Copyright (C) 2006-2015 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,138 +82,138 @@ if (! is_array($user_arbo) && $user_arbo < 0) } else { -// Define fulltree array -$fulltree=$user_arbo; -//var_dump($fulltree); -// Define data (format for treeview) -$data=array(); -$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); -foreach($fulltree as $key => $val) -{ - $userstatic->id=$val['id']; - $userstatic->ref=$val['label']; - $userstatic->login=$val['login']; - $userstatic->firstname=$val['firstname']; - $userstatic->lastname=$val['lastname']; - $userstatic->statut=$val['statut']; - $userstatic->email=$val['email']; - $userstatic->gender=$val['gender']; - $userstatic->societe_id=$val['fk_soc']; - $userstatic->admin=$val['admin']; - $userstatic->entity=$val['entity']; - $userstatic->photo=$val['photo']; + // Define fulltree array + $fulltree=$user_arbo; + //var_dump($fulltree); + // Define data (format for treeview) + $data=array(); + $data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); + foreach($fulltree as $key => $val) + { + $userstatic->id=$val['id']; + $userstatic->ref=$val['label']; + $userstatic->login=$val['login']; + $userstatic->firstname=$val['firstname']; + $userstatic->lastname=$val['lastname']; + $userstatic->statut=$val['statut']; + $userstatic->email=$val['email']; + $userstatic->gender=$val['gender']; + $userstatic->societe_id=$val['fk_soc']; + $userstatic->admin=$val['admin']; + $userstatic->entity=$val['entity']; + $userstatic->photo=$val['photo']; - $entity=$val['entity']; - $entitystring=''; + $entity=$val['entity']; + $entitystring=''; - // TODO Set of entitystring should be done with a hook - if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($entity)) - { - $entitystring=$langs->trans("AllEntities"); - } - else - { - $mc->getInfo($entity); - $entitystring=$mc->label; - } - } + // TODO Set of entitystring should be done with a hook + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + if (empty($entity)) + { + $entitystring=$langs->trans("AllEntities"); + } + else + { + $mc->getInfo($entity); + $entitystring=$mc->label; + } + } - $li=$userstatic->getNomUrl(-1, '', 0, 1); - if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity) - { - $li.=img_picto($langs->trans("SuperAdministrator"), 'redstar'); - } - elseif ($userstatic->admin) - { - $li.=img_picto($langs->trans("Administrator"), 'star'); - } - $li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')'; + $li=$userstatic->getNomUrl(-1, '', 0, 1); + if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity) + { + $li.=img_picto($langs->trans("SuperAdministrator"), 'redstar'); + } + elseif ($userstatic->admin) + { + $li.=img_picto($langs->trans("Administrator"), 'star'); + } + $li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')'; - $data[] = array( - 'rowid'=>$val['rowid'], - 'fk_menu'=>$val['fk_user'], - 'statut'=>$val['statut'], - 'entry'=>'
    '.$li.''.$userstatic->getLibStatut(3).'
    ' - ); -} + $data[] = array( + 'rowid'=>$val['rowid'], + 'fk_menu'=>$val['fk_user'], + 'statut'=>$val['statut'], + 'entry'=>'
    '.$li.''.$userstatic->getLibStatut(3).'
    ' + ); + } -//var_dump($data); + //var_dump($data); -$title = $langs->trans("ListOfUsers"). ' - '.$langs->trans("HierarchicView"); + $title = $langs->trans("ListOfUsers"). ' - '.$langs->trans("HierarchicView"); -$param="search_statut=".urlencode($search_statut); + $param="search_statut=".urlencode($search_statut); -$newcardbutton=''; -if ($canadduser) -{ - $newcardbutton.= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1': '').'&leftmenu='); -} + $newcardbutton=''; + if ($canadduser) + { + $newcardbutton.= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1': '').'&leftmenu='); + } -$morehtmlright.= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/user/list.php'.(($search_statut != '' && $search_statut >= 0) ?'?search_statut='.$search_statut:'')); + $morehtmlright.= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list paddingleft', DOL_URL_ROOT.'/user/list.php'.(($search_statut != '' && $search_statut >= 0) ?'?search_statut='.$search_statut:'')); -print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton); + print load_fiche_titre($title, $morehtmlright.' '.$newcardbutton); -print '
    '."\n"; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; + print ''."\n"; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; -print ''; + print '
    '; -print ''; -print ''; -print ''; -// Status -print ''; -print ''; -print ''; + print ''; + print ''; + print ''; + // Status + print ''; + print ''; + print ''; -print ''; -print_liste_field_titre("HierarchicView"); -print_liste_field_titre('', $_SERVER['PHP_SELF'], "", '', "", 'align="center"'); -print_liste_field_titre("Status", $_SERVER['PHP_SELF'], "", '', "", 'align="right"'); -print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); -print ''; + print ''; + print_liste_field_titre("HierarchicView"); + print_liste_field_titre('', $_SERVER['PHP_SELF'], "", '', "", 'align="center"'); + print_liste_field_titre("Status", $_SERVER['PHP_SELF'], "", '', "", 'align="right"'); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', '', '', 'maxwidthsearch '); + print ''; -$nbofentries=(count($data) - 1); + $nbofentries=(count($data) - 1); -if ($nbofentries > 0) -{ - print ''; - print ''; - print ''; -} -else -{ - print ''; - print ''; - print ''; - print ''; -} + if ($nbofentries > 0) + { + print ''; + print ''; + print ''; + } + else + { + print ''; + print ''; + print ''; + print ''; + } -print "
      '; -print $form->selectarray('search_statut', array('-1'=>'','1'=>$langs->trans('Enabled')), $search_statut); -print ''; -$searchpicto=$form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print '
      '; + print $form->selectarray('search_statut', array('-1'=>'','1'=>$langs->trans('Enabled')), $search_statut); + print ''; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
    '; - tree_recur($data, $data[0], 0); - print '
    '; - print ''; - print ''; - print ''; - print '
    '.img_picto_common('', 'treemenu/branchbottom.gif').''; - print $langs->trans("NoCategoryYet"); - print ' 
    '; - print '
    '; + tree_recur($data, $data[0], 0); + print '
    '; + print ''; + print ''; + print ''; + print '
    '.img_picto_common('', 'treemenu/branchbottom.gif').''; + print $langs->trans("NoCategoryYet"); + print ' 
    '; + print '
    "; -print "
    \n"; + print ""; + print "\n"; } // diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 95b9529017c..3b334871c06 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -27,21 +27,24 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (! empty($conf->categorie->enabled)) +if (! empty($conf->categorie->enabled)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} -if (! $user->rights->user->user->lire && ! $user->admin) +if (! $user->rights->user->user->lire && ! $user->admin) { accessforbidden(); +} - // Load translation files required by page +// Load translation files required by page $langs->loadLangs(array('users', 'companies', 'hrm')); $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'userlist'; // To manage different context of search // Security check (for external users) $socid=0; -if ($user->societe_id > 0) +if ($user->societe_id > 0) { $socid = $user->societe_id; +} // Load mode employee $mode = GETPOST("mode", 'alpha'); @@ -535,29 +538,29 @@ while ($i < min($num, $limit)) } if (! empty($arrayfields['u.firstname']['checked'])) { - print ''.$obj->firstname.''; + print ''.$obj->firstname.''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.gender']['checked'])) { - print ''; - if ($obj->gender) print $langs->trans("Gender".$obj->gender); - print ''; + print ''; + if ($obj->gender) print $langs->trans("Gender".$obj->gender); + print ''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.employee']['checked'])) { - print ''.yn($obj->employee).''; + print ''.yn($obj->employee).''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.accountancy_code']['checked'])) { - print ''.$obj->accountancy_code.''; + print ''.$obj->accountancy_code.''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.email']['checked'])) { - print ''.$obj->email.''; + print ''.$obj->email.''; if (! $i) $totalarray['nbfield']++; } if (! empty($arrayfields['u.api_key']['checked'])) @@ -580,7 +583,7 @@ while ($i < min($num, $limit)) print $langs->trans("DomainUser"); } else - { + { print $langs->trans("InternalUser"); } print ''; @@ -673,9 +676,9 @@ while ($i < min($num, $limit)) // Status if (! empty($arrayfields['u.statut']['checked'])) { - $userstatic->statut=$obj->statut; - print ''.$userstatic->getLibStatut(3).''; - if (! $i) $totalarray['nbfield']++; + $userstatic->statut=$obj->statut; + print ''.$userstatic->getLibStatut(3).''; + if (! $i) $totalarray['nbfield']++; } // Action column print ''; diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index b48823d2aa0..577af6c04ba 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -208,7 +208,7 @@ if ($result > 0) print "\n"; -// $listofemails=$object->thirdparty_and_contact_email_array(); + // $listofemails=$object->thirdparty_and_contact_email_array(); if ($object->email) { $actions=array(); @@ -294,7 +294,7 @@ if ($result > 0) if ($num) { - $i = 0; + $i = 0; $userstatic=new user($db); diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index b6bfb90e22c..3e89df4e587 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -35,11 +35,11 @@ if ($_POST) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } - if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } else { - setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); - } + if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + } else { + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + } } $title = $langs->trans('ModuleSetup').' '.$langs->trans('ProductAttributes'); diff --git a/htdocs/variants/ajax/getCombinations.php b/htdocs/variants/ajax/getCombinations.php index 6f028f5aa8b..38affc574d2 100644 --- a/htdocs/variants/ajax/getCombinations.php +++ b/htdocs/variants/ajax/getCombinations.php @@ -31,18 +31,18 @@ header('Content-Type: application/json'); $id = GETPOST('id', 'int'); if (!$id) { -print json_encode(array( - 'error' => 'ID not set' - )); - exit(); + print json_encode(array( + 'error' => 'ID not set' + )); + exit(); } $product = new Product($db); if ($product->fetch($id) < 0) { -print json_encode(array( - 'error' => 'Product not found' - )); + print json_encode(array( + 'error' => 'Product not found' + )); } $prodcomb = new ProductCombination($db); diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index 0d72b16c5ed..866bac1ef78 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -31,19 +31,19 @@ header('Content-Type: application/json'); $id = GETPOST('id'); if (!$id) { -print json_encode(array( - 'error' => 'ID not set' - )); - exit(); + print json_encode(array( + 'error' => 'ID not set' + )); + exit(); } $prodattr = new ProductAttribute($db); if ($prodattr->fetch($id) < 0) { -print json_encode(array( - 'error' => 'Attribute not found' - )); - exit(); + print json_encode(array( + 'error' => 'Attribute not found' + )); + exit(); } $prodattrval = new ProductAttributeValue($db); @@ -51,10 +51,10 @@ $prodattrval = new ProductAttributeValue($db); $res = $prodattrval->fetchAllByProductAttribute($id); if ($res == -1) { -print json_encode(array( - 'error' => 'Internal error' - )); - exit(); + print json_encode(array( + 'error' => 'Internal error' + )); + exit(); } print json_encode($res); diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index e425aa16c5d..5847aa259b4 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -144,58 +144,54 @@ if ($action == 'edit') { } -if ($action != 'edit') -{ +if ($action != 'edit') { print '
    '; print '
    '; } -?> - - - - - - - - - +print '
    trans('Ref') ?> - ref.'">'; - } else { - print dol_htmlentities($object->ref); - } ?> -
    trans('Label') ?> - label.'">'; - } else { - print dol_htmlentities($object->label); - } ?> -
    '; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; -
    '.$langs->trans('Ref').''; +if ($action == 'edit') { + print ''; +} else { + print dol_htmlentities($object->ref); +} +print '
    '.$langs->trans('Label').''; +if ($action == 'edit') { + print ''; +} else { + print dol_htmlentities($object->label); +} +print '
    +print ''; -'; } dol_fiche_end(); -if ($action == 'edit') { ?> -
    -
    - -     - -
    -
    -'; + print '
    '; + print ''; + print '   '; + print ''; + print '
    '; + print '
    '; +} else { if ($action == 'delete') { $form = new Form($db); -print $form->formconfirm( + print $form->formconfirm( "card.php?id=".$object->id, $langs->trans('Delete'), $langs->trans('ProductAttributeDeleteDialog'), @@ -208,7 +204,7 @@ print $form->formconfirm( if ($objectval->fetch($valueid) > 0) { $form = new Form($db); -print $form->formconfirm( + print $form->formconfirm( "card.php?id=".$object->id."&valueid=".$objectval->id, $langs->trans('Delete'), $langs->trans('ProductAttributeValueDeleteDialog', dol_htmlentities($objectval->value), dol_htmlentities($objectval->ref)), @@ -241,20 +237,19 @@ print $form->formconfirm( print ''; print ''; print ''; - } ?> + } - - - - - - + print '
    trans('Ref') ?>trans('Value') ?>
    '; + print ''; + print ''; + print ''; + print ''; + print ''; - fetchAllByProductAttribute($object->id) as $attrval) { - ?> - - id)): ?> + foreach ($objectval->fetchAllByProductAttribute($object->id) as $attrval) { + print ''; + if ($action == 'edit_value' && ($valueid == $attrval->id)) { + ?> - + - - - -
    '.$langs->trans('Ref').''.$langs->trans('Value').'
    @@ -262,31 +257,30 @@ print $form->formconfirm(     ref) ?> value) ?>
    + print ''; + } + print ''; - - - + if ($action == 'edit_value') { + print ''; + } - - - '; + print '
    '; + print ''.$langs->trans('Create').''; + print '
    '; + print '
    '; } // End of page diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index db0d49a0e36..21346d6124e 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -572,9 +572,9 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1"; } if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { - $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; + $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref; } else { - $newproduct->ref .= '_'.$prodattrval->ref; + $newproduct->ref .= '_'.$prodattrval->ref; } //The first one should not contain a linebreak diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index e5f1d17b8aa..a87959e76fb 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -425,7 +425,7 @@ if (! empty($id) || ! empty($ref)) fetch($pc2v->fk_prod_attr_val); - ?> + ?> variants_selected.index.push(fk_prod_attr ?>); variants_selected.info[fk_prod_attr ?>] = { attribute: variants_available[fk_prod_attr ?>], @@ -434,7 +434,7 @@ if (! empty($id) || ! empty($ref)) label: 'value ?>' } }; - @@ -484,7 +484,7 @@ if (! empty($id) || ! empty($ref)) }); - '; @@ -495,40 +495,36 @@ if (! empty($id) || ! empty($ref)) print ''; print ''."\n"; print ''."\n"; - if($valueid > 0) { + if ($valueid > 0) { print ''."\n"; } print dol_fiche_head(); - ?> - - - - - - '; + print '
    - '; - print ''; - foreach ($prodattr_all as $attr) - { - //print ''; - print ''; - } - print ''; + print ''; + if ($action == 'add') { + print "\n"; + print ''; + print ''; + print ' @@ -555,15 +551,14 @@ if (! empty($id) || ! empty($ref)) - -
    '; + if (is_array($prodattr_all)) { + print ''; + } - $htmltext=$langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); - print $form->textwithpicto('', $htmltext); - /*print '     id).'">'; - print $langs->trans("Create"); - print '';*/ + $htmltext=$langs->trans("GoOnMenuToCreateVairants", $langs->transnoentities("Product"), $langs->transnoentities("VariantAttributes")); + print $form->textwithpicto('', $htmltext); + /*print '     id).'">'; + print $langs->trans("Create"); + print '';*/ - ?> + ?>
    - -
    - '; + print '
    '; + } if (is_array($productCombination2ValuePairs1)) { - ?> + ?>
    @@ -597,7 +592,7 @@ if (! empty($id) || ! empty($ref)) -isProduct()) { print ''; print ''; @@ -644,7 +639,7 @@ if (! empty($id) || ! empty($ref)) if ($productCombinations) { - ?> + ?>
    >