diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 0db18adcf80..30b33e70db8 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -57,7 +57,6 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["main_multilangs"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_USE_PREVIEW_TABS", $_POST["main_use_preview_tabs"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity); @@ -74,7 +73,9 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0); // Param for all entities - dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity); + + // This one is not always defined + if (isset($_POST["MAIN_USE_PREVIEW_TABS"])) dolibarr_set_const($db, "MAIN_USE_PREVIEW_TABS", $_POST["MAIN_USE_PREVIEW_TABS"],'chaine',0,'',$conf->entity); $_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer @@ -187,7 +188,7 @@ if ($action == 'edit') // Edit { $var=!$var; print ''.$langs->trans("UsePreviewTabs").''; - print $form->selectyesno('main_use_preview_tabs',isset($conf->global->MAIN_USE_PREVIEW_TABS)?$conf->global->MAIN_USE_PREVIEW_TABS:0,1); + print $form->selectyesno('MAIN_USE_PREVIEW_TABS',isset($conf->global->MAIN_USE_PREVIEW_TABS)?$conf->global->MAIN_USE_PREVIEW_TABS:0,1); print ''; print ' '; print ''; @@ -237,7 +238,7 @@ if ($action == 'edit') // Edit // Message on login page $var=!$var; print ''.$langs->trans("MessageLogin").''; - + $doleditor = new DolEditor('main_home', (isset($conf->global->MAIN_HOME)?$conf->global->MAIN_HOME:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, 90); $doleditor->Create(); @@ -246,22 +247,12 @@ if ($action == 'edit') // Edit // Message of the day on home page $var=!$var; print ''.$langs->trans("MessageOfDay").''; - + $doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, 90); $doleditor->Create(); print ''."\n"; - /* - // Show bugtrack link - $var=!$var; - print ''.$langs->trans("ShowBugTrackLink").''; - print $form->selectyesno('main_show_bugtrack_link',$conf->global->MAIN_BUGTRACK_ENABLELINK,1); - print ''; - print ' '; - print ''; - */ - print ''."\n"; @@ -401,15 +392,6 @@ else // Show else print ' '; print ''."\n"; - /* - // Show bugtrack link - $var=!$var; - print ''.$langs->trans("ShowBugTrackLink").''; - print yn($conf->global->MAIN_BUGTRACK_ENABLELINK).""; - print ' '; - print ""; - */ - print ''."\n"; print '
'; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 7dd553b0046..ff28de54e80 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -912,7 +912,8 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa 0, $fournprice, $buying_price, - $label + $label, + $type ); if ($result >= 0) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a548153f91d..65287b23e57 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * @@ -352,7 +352,7 @@ class Propal extends CommonObject // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits,$type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -463,9 +463,10 @@ class Propal extends CommonObject * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price without tax * @param string $label ??? + * @param int $type 0/1=Product/service * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='') + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0) { global $conf,$user,$langs; @@ -491,7 +492,7 @@ class Propal extends CommonObject // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6d6181ad75c..ee3f627f073 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -999,6 +999,7 @@ class Commande extends CommonOrder * @param int $fk_parent_line Parent line * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price (without tax) + * @param string $label Label * @return int >0 if OK, <0 if KO * * @see add_product @@ -1054,7 +1055,7 @@ class Commande extends CommonOrder // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits,$type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2159,6 +2160,7 @@ class Commande extends CommonOrder * @param int $skip_update_total Skip update of total * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price (without tax) + * @param string $label Label * @return int < 0 if KO, > 0 if OK */ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0,$txlocaltax2=0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='') @@ -2192,7 +2194,7 @@ class Commande extends CommonOrder // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2682,7 +2684,7 @@ class Commande extends CommonOrder $line->total_ht=100; $line->total_ttc=119.6; $line->total_tva=19.6; - $line->remise_percent=00; + $line->remise_percent=0; } $prodid = rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; @@ -2841,13 +2843,15 @@ class OrderLine var $localtax2_tx; // Local tax 2 var $subprice; // U.P. HT (example 100) var $remise_percent; // % for line discount (example 20%) + var $fk_remise_except; var $rang = 0; var $fk_fournprice; var $pa_ht; var $marge_tx; var $marque_tx; var $info_bits = 0; // Bit 0: 0 si TVA normal - 1 si TVA NPR - // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + // Bit 1: 0 ligne normale - 1 si ligne de remise fixe + var $special_code = 0; var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne var $total_localtax1; // Total local tax 1 for the line diff --git a/htdocs/commissions/admin/commissions.php b/htdocs/commissions/admin/commissions.php index 42ff3f4b75e..de9b5761ecb 100644 --- a/htdocs/commissions/admin/commissions.php +++ b/htdocs/commissions/admin/commissions.php @@ -24,8 +24,11 @@ include '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/commissions/lib/commissions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); +require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); $langs->load("admin"); +$langs->load("bills"); $langs->load("commissions"); if (! $user->admin) accessforbidden(); @@ -69,6 +72,17 @@ if (GETPOST('serviceCommissionRate')) } } +if (GETPOST('AGENT_CONTACT_TYPE')) +{ + if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', GETPOST('AGENT_CONTACT_TYPE'), 'chaine', 0, '', $conf->entity) > 0) + { + $conf->global->AGENT_CONTACT_TYPE = GETPOST('AGENT_CONTACT_TYPE'); + } + else + { + dol_print_error($db); + } +} /* * View @@ -146,6 +160,18 @@ print ''; print ''.$langs->trans('ServiceCommissionRateDetails').''; print ''; +// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT +$var=!$var; +print ''; +print ''.$langs->trans("AgentContactType").''; +print ''; +$formcompany = new FormCompany($db); +$facture = new Facture($db); +print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1); +print ''; +print ''.$langs->trans('AgentContactTypeDetails').''; +print ''; + $var=!$var; print ''; print ''; @@ -153,7 +179,6 @@ print ''; print ''; print ''; - print ''; print ''; diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php index 0a9c37abb4b..4a68cb8bbd1 100644 --- a/htdocs/commissions/index.php +++ b/htdocs/commissions/index.php @@ -134,44 +134,52 @@ print ''; print ""; print ''; -$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; +$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; $sql.= " u.login,"; -$sql.= " f.facnumber, f.total as total_ht,"; if ($conf->global->COMMISSION_BASE == "MARGIN") { $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ; + $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase" ; } elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase," ; + $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase" ; } -$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ", ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND sc.fk_soc = f.fk_soc"; -$sql.= " AND sc.fk_user = u.rowid"; +if (! empty($conf->global->AGENT_CONTACT_TYPE)) + $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; +else + $sql .= " AND sc.fk_user = u.rowid"; if (GETPOST('unpayed') == 'on') $sql.= " AND f.fk_statut > 0"; else $sql.= " AND f.fk_statut > 1"; $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND d.fk_facture = f.rowid"; -if ($agentid > 0) - $sql.= " AND sc.fk_user = $agentid"; +if ($agentid > 0) { + if (! empty($conf->global->AGENT_CONTACT_TYPE)) + $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; + else + $sql .= " AND sc.fk_user = ".$agentid; +} if (!empty($startdate)) $sql.= " AND f.datef >= '".$startdate."'"; if (!empty($enddate)) $sql.= " AND f.datef <= '".$enddate."'"; +if ($conf->global->COMMISSION_BASE == "MARGIN") + $sql .= " AND d.buy_price_ht IS NOT NULL"; if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; if ($agentid > 0) $sql.= " GROUP BY s.rowid"; else - $sql.= " GROUP BY sc.fk_user"; + $sql.= " GROUP BY u.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -219,6 +227,7 @@ if ($result) $cumul_base_service = 0; $cumul_commission_produit = 0; $cumul_commission_service = 0; + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) { $var=True; @@ -260,22 +269,22 @@ if ($result) // total commission print "".price($productCommission + $serviceCommission)."\n"; print "\n"; + $i++; - $cumul_base_produit += $productBase; - $cumul_base_service += $serviceBase; - $cumul_commission_produit += $productCommission; - $cumul_commission_service += $serviceCommission; + + $cumul_base_produit += round($productBase, $rounding); + $cumul_base_service += round($serviceBase, $rounding); + $cumul_commission_produit += round($productCommission, $rounding); + $cumul_commission_service += round($serviceCommission, $rounding); } } // affichage totaux commission $var=!$var; print ''; - if (! empty($client)) - print ''; - else - print ''; - print $langs->trans('TotalCommission').""; + print ''; + print $langs->trans('Total'); + print ""; // product commission print "".price($cumul_base_produit)."\n"; print "".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."\n"; @@ -289,6 +298,7 @@ if ($result) print "\n"; + print ""; print ""; } else diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6f6c85abd59..004ca90fcc4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -691,7 +691,7 @@ class Facture extends CommonInvoice // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) + if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } @@ -1330,6 +1330,8 @@ class Facture extends CommonInvoice if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id; + $cdr_nbjour=0; $cdr_fdm=0; $cdr_decalage=0; + $sqltemp = 'SELECT c.fdm,c.nbjour,c.decalage'; $sqltemp.= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; if (is_numeric($cond_reglement)) $sqltemp.= " WHERE c.rowid=".$cond_reglement; @@ -1925,7 +1927,7 @@ class Facture extends CommonInvoice // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -2063,7 +2065,7 @@ class Facture extends CommonInvoice // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2ef81f12248..08a36521640 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -24,8 +24,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** - * \class CommonInvoice - * \brief Superclass for invoices classes + * Superclass for invoices classes */ abstract class CommonInvoice extends CommonObject { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ebcdd51fc88..446d6cdf984 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -665,7 +665,7 @@ class FormFile print ''; print "\n"; print ''.dol_print_size($file['size'],1,1).''; - print ''.dol_print_date($file['date'],"dayhour").''; + print ''.dol_print_date($file['date'],"dayhour","tzuser").''; // Preview if (empty($useinecm)) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index b020febd3b0..92399378f53 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -47,25 +47,16 @@ function dol_basename($pathfile) * @param string $sortcriteria Sort criteria ("","fullname","name","date","size") * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only + * @param int $nohook Disable all hooks * @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file') */ -function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0) +function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=false) { global $db, $hookmanager; global $object; dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter)); - if (! is_object($hookmanager)) - { - if (! class_exists('HookManager')) { - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array - require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($db); - } - } - $hookmanager->initHooks(array('fileslib')); - $loaddate=($mode==1||$mode==2)?true:false; $loadsize=($mode==1||$mode==3)?true:false; @@ -73,23 +64,35 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil $path=preg_replace('/([\\/]+)$/i','',$path); $newpath=dol_osencode($path); - $parameters=array( - 'path' => $newpath, - 'types'=> $types, - 'recursive' => $recursive, - 'filter' => $filter, - 'excludefilter' => $excludefilter, - 'sortcriteria' => $sortcriteria, - 'sortorder' => $sortorder, - 'loaddate' => $loaddate, - 'loadsize' => $loadsize - ); - $reshook=$hookmanager->executeHooks('getNodesList', $parameters, $object); + if (! $nohook) { + if (! is_object($hookmanager)) + { + if (! class_exists('HookManager')) { + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + require DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($db); + } + } + $hookmanager->initHooks(array('fileslib')); + + $parameters=array( + 'path' => $newpath, + 'types'=> $types, + 'recursive' => $recursive, + 'filter' => $filter, + 'excludefilter' => $excludefilter, + 'sortcriteria' => $sortcriteria, + 'sortorder' => $sortorder, + 'loaddate' => $loaddate, + 'loadsize' => $loadsize + ); + $reshook=$hookmanager->executeHooks('getNodesList', $parameters, $object); + } // $reshook may contain returns stacked by other modules // $reshook is always empty with an array for can not lose returns stacked with other modules // $hookmanager->resArray may contain array stacked by other modules - if (! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty + if (! $nohook && ! empty($hookmanager->resArray)) // forced to use $hookmanager->resArray even if $hookmanager->resArray['nodes'] is empty { return $hookmanager->resArray['nodes']; } @@ -512,13 +515,13 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) /** * Move a file into another name. + * This function differs from dol_move_uploaded_file, because it can be called in any context. * * @param string $srcfile Source file (can't be a directory) * @param string $destfile Destination file (can't be a directory) * @param string $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK) * @param int $overwriteifexists Overwrite file if exists (1 by default) * @return boolean True if OK, false if KO - * @see dol_move_uploaded_file */ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1) { @@ -840,7 +843,8 @@ function dol_delete_preview($object) { global $langs,$conf; - $element = $object->element; + // Define parent dir of elements + $element = $object->element; if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; @@ -848,8 +852,7 @@ function dol_delete_preview($object) elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; - else - $dir = $conf->$element->dir_output; + else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; if (empty($dir)) return 'ErrorObjectNoSupportedByFunction'; @@ -898,11 +901,18 @@ function dol_meta_create($object) { global $conf; - if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; + if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. // Define parent dir of elements $element=$object->element; - $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; + + if ($object->element == 'order_supplier') $dir = $conf->fournisseur->dir_output.'/commande'; + elseif ($object->element == 'invoice_supplier') $dir = $conf->fournisseur->dir_output.'/facture'; + elseif ($object->element == 'project') $dir = $conf->projet->dir_output; + elseif ($object->element == 'shipping') $dir = $conf->expedition->dir_output.'/sending'; + elseif ($object->element == 'delivery') $dir = $conf->expedition->dir_output.'/receipt'; + elseif ($object->element == 'fichinter') $dir = $conf->ficheinter->dir_output; + else $dir=empty($conf->$element->dir_output)?'':$conf->$element->dir_output; if ($dir) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5826e248b13..1a4aa60a012 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3419,10 +3419,10 @@ function dol_textishtml($msg,$option=0) function dol_concatdesc($text1,$text2,$forxml=false) { $ret=''; - $ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1; - $ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"
\n":"
\n") : "\n") : ""; + $ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1; + $ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"
\n":"
\n") : "\n") : ""; $ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2; - return $ret; + return $ret; } /** @@ -4003,7 +4003,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= if (verifCond($values[4])) { if ($values[3]) $langs->load($values[3]); - $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[5]),1); + $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', (! empty($object->id)?$object->id:''), $values[5]), 1); $head[$h][1] = $langs->trans($values[2]); $head[$h][2] = str_replace('+','',$values[1]); $h++; @@ -4013,7 +4013,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= { if ($values[0] != $type) continue; if ($values[3]) $langs->load($values[3]); - $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[4]),1); + $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', (! empty($object->id)?$object->id:''), $values[4]), 1); $head[$h][1] = $langs->trans($values[2]); $head[$h][2] = str_replace('+','',$values[1]); $h++; @@ -4022,7 +4022,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= { if ($values[0] != $type) continue; if ($values[2]) $langs->load($values[2]); - $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i',$object->id,$values[3]),1); + $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', (! empty($object->id)?$object->id:''), $values[3]), 1); $head[$h][1] = $langs->trans($values[1]); $head[$h][2] = 'tab'.$values[1]; $h++; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c63360a07ad..38456afc255 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1230,7 +1230,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0) if (! $tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt'); + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); } } diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index b6df4922534..cf3fa89c655 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -267,7 +267,7 @@ function _unval($val) { // single, escaped unicode character $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); - $utf8 .= utf162utf8($utf16); + $utf8 = utf162utf8($utf16); $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); } return $val; diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 78a357cd71b..d6188ec75a0 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2008 Laurent Destailleur - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2012 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -58,7 +58,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $localtax1 // TODO Remove this code. Added for backward compatibility. To remove once localtaxX_type is provided by caller. if ($localtax1_type == '?') { - if ($mysoc->country_code=='ES') $localtax1_type='1'; + if ($mysoc->country_code=='ES') $localtax1_type='3'; else $localtax1_type='0'; } if ($localtax2_type == '?') diff --git a/htdocs/core/login/functions_http.php b/htdocs/core/login/functions_http.php index c40e3b1609d..8aea6d40a2c 100644 --- a/htdocs/core/login/functions_http.php +++ b/htdocs/core/login/functions_http.php @@ -33,7 +33,7 @@ */ function check_user_password_http($usertotest,$passwordtotest,$entitytotest) { - dol_syslog("functions_http::check_user_password_http _SERVER[REMOTE_USER]=".$_SERVER["REMOTE_USER"]); + dol_syslog("functions_http::check_user_password_http _SERVER[REMOTE_USER]=".(empty($_SERVER["REMOTE_USER"])?'':$_SERVER["REMOTE_USER"])); $login=''; if (! empty($_SERVER["REMOTE_USER"])) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 5a384852cba..7bcbc8e8057 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -112,7 +112,7 @@ class CommActionRapport if (file_exists($dir)) { $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index c56f20f8773..4fd48630869 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -115,7 +115,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts // Create PDF instance $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index a39c4a5a4a6..b0561ed7310 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2012 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 @@ -177,7 +177,7 @@ class pdf_einstein extends ModelePDFCommandes $nblignes = count($object->lines); $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part (value include bottom margin) $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -261,9 +261,10 @@ class pdf_einstein extends ModelePDFCommandes for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -379,13 +380,13 @@ class pdf_einstein extends ModelePDFCommandes // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } // Affiche zone infos @@ -620,7 +621,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -628,7 +629,7 @@ class pdf_einstein extends ModelePDFCommandes $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && is_float($this->tva['0.000'])) ? true : false); + $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { // Nothing to do @@ -694,7 +695,7 @@ class pdf_einstein extends ModelePDFCommandes //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++; @@ -722,7 +723,7 @@ class pdf_einstein extends ModelePDFCommandes //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++; @@ -760,7 +761,13 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0,0,0); - $resteapayer = price2num($object->total_ttc - $deja_regle); + $creditnoteamount=0; + $depositsamount=0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) { diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index c7e7c4c1744..29b8eea38f0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -70,13 +70,18 @@ class pdf_expedition_merou extends ModelePdfExpedition /** - * Fonction generant le document sur le disque + * Function to build pdf onto disk * - * @param Object &$object Objet expedition a generer (ou id si ancienne methode) - * @param Translate $outputlangs Lang output object - * @return int 1=ok, 0=ko + * @param Object &$object Object expedition to generate (or id if old method) + * @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 + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ - function write_file(&$object, $outputlangs) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { global $user,$conf,$langs,$mysoc; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -108,12 +113,12 @@ class pdf_expedition_merou extends ModelePdfExpedition //Creation du destinataire $idcontact = $object->$origin->getIdContact('external','SHIPPING'); $this->destinataire = new Contact($this->db); - if ($idcontact[0]) $this->destinataire->fetch($idcontact[0]); + if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); //Creation du livreur $idcontact = $object->$origin->getIdContact('internal','LIVREUR'); $this->livreur = new User($this->db); - if ($idcontact[0]) $this->livreur->fetch($idcontact[0]); + if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); // Definition de $dir et $file if ($object->specimen) @@ -142,7 +147,8 @@ class pdf_expedition_merou extends ModelePdfExpedition $nblignes = count($object->lines); $pdf=pdf_getInstance($this->format,'mm','l'); - $heightforfooter = 28; // Height reserved to output the footer (value include bottom margin) + $heightforinfotot = 0; // Height reserved to output the info and total part + $heightforfooter = 28; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); if (class_exists('TCPDF')) @@ -195,10 +201,12 @@ class pdf_expedition_merou extends ModelePdfExpedition $nexY = $tab_top + 7; $num=count($object->lines); + // Loop on each lines for ($i = 0; $i < $num; $i++) { $curY = $nexY; $pdf->SetFont('','', $default_font_size - 3); + $pdf->SetTextColor(0,0,0); $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. @@ -273,13 +281,13 @@ class pdf_expedition_merou extends ModelePdfExpedition // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } // Pied de page diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index 4a28d6d257c..9ef088bb9a3 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2009 Laurent Destailleur + * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -73,13 +73,18 @@ class pdf_expedition_rouget extends ModelePdfExpedition } /** - * Fonction generant le document sur le disque + * Function to build pdf onto disk * - * @param Object &$object Objet expedition a generer (ou id si ancienne methode) - * @param Translate $outputlangs Lang output object - * @return int 1=ok, 0=ko + * @param Object &$object Object expedition to generate (or id if old method) + * @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 + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ - function write_file(&$object, $outputlangs) + function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { global $user,$conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -128,7 +133,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition $nblignes = count($object->lines); $pdf=pdf_getInstance($this->format); - $heightforinfotot = 0; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 0; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -223,12 +228,14 @@ class pdf_expedition_rouget extends ModelePdfExpedition $nexY = $tab_top + 7; $num=count($object->lines); + // Loop on each lines for ($i = 0; $i < $num; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index bbb503b7aa2..8f2198928a8 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2010-2012 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 @@ -119,14 +119,14 @@ class pdf_crabe extends ModelePDFFactures /** * Function to build pdf onto disk * - * @param int $object Id of object to generate - * @param object $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 - * @param object $hookmanager Hookmanager object - * @return int 1=OK, 0=KO + * @param Object $object Object to generate + * @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 + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { @@ -178,7 +178,7 @@ class pdf_crabe extends ModelePDFFactures $nblignes = count($object->lines); $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -264,7 +264,8 @@ class pdf_crabe extends ModelePDFFactures for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. @@ -382,12 +383,12 @@ class pdf_crabe extends ModelePDFFactures if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } // Affiche zone infos @@ -744,7 +745,6 @@ class pdf_crabe extends ModelePDFFactures $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { - $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false); if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull) { @@ -809,7 +809,7 @@ class pdf_crabe extends ModelePDFFactures //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++; @@ -837,7 +837,7 @@ class pdf_crabe extends ModelePDFFactures //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++; diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index d5d05aac1c3..dde7c8dfd78 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -177,7 +177,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0,0,0); + $pdf->SetTextColor(0,0,0); $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); @@ -245,9 +245,10 @@ class pdf_soleil extends ModelePDFFicheinter if ($valide > 0 || $object->specimen) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -257,7 +258,7 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0); - $nexY = $pdf->GetY(); + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); @@ -310,12 +311,12 @@ class pdf_soleil extends ModelePDFFicheinter if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforfooter + 1; + $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforfooter + 1; + $bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfooter + 1; } $this->_pagefoot($pdf,$object,$outputlangs); @@ -394,8 +395,8 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->SetXY(20,230); $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); - $pdf->SetXY(20,235); - $pdf->MultiCell(80,25, '', 1); + $pdf->SetXY(20,235); + $pdf->MultiCell(80,25, '', 1); $pdf->SetXY(110,230); $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); diff --git a/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php index ca1d1a937d1..719a0d98bee 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * \class pdf_sirocco - * \brief Classe permettant de generer les bons de livraison au modele Sirocco + * Classe permettant de generer les bons de livraison au modele Sirocco */ class pdf_sirocco extends ModelePDFDeliveryOrder { @@ -120,7 +119,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if (file_exists($dir)) { $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -180,12 +179,14 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $curY = $tab_top + 7; $nexY = $tab_top + 7; + // Loop on each lines for ($i = 0 ; $i < $nblines ; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -268,13 +269,13 @@ if ($pageposafter > $pageposbefore) { // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } /* diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index 9cc0de35648..da54ea642bd 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; /** - * \class pdf_typhon - * \brief Classe permettant de generer les bons de livraison au modele Typho + * Classe permettant de generer les bons de livraison au modele Typho */ - class pdf_typhon extends ModelePDFDeliveryOrder { var $emetteur; // Objet societe qui emet @@ -143,7 +141,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (file_exists($dir)) { $pdf=pdf_getInstance($this->format); - $heightforinfotot = 50; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 50; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -236,13 +234,14 @@ class pdf_typhon extends ModelePDFDeliveryOrder $curY = $tab_top + 7; $nexY = $tab_top + 7; - // Boucle sur les lignes + // Loop on each lines for ($i = 0 ; $i < $nblines ; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot-50); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -336,13 +335,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } /* diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index dea29ca8bdb..23352041b33 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -127,7 +127,7 @@ class pdf_baleine extends ModelePDFProjects if (file_exists($dir)) { $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -265,13 +265,13 @@ class pdf_baleine extends ModelePDFProjects // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } /* diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6a479426012..704171866e6 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -117,14 +117,14 @@ class pdf_azur extends ModelePDFPropales /** * Function to build pdf onto disk * - * @param int $object Id of object to generate - * @param object $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 - * @param object $hookmanager Hookmanager object - * @return int 1=OK, 0=KO + * @param Object $object Object to generate + * @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 + * @param object $hookmanager Hookmanager object + * @return int 1=OK, 0=KO */ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) { @@ -147,7 +147,7 @@ class pdf_azur extends ModelePDFPropales { $object->fetch_thirdparty(); - $deja_regle = ""; // FIXME not use in proposal? + // $deja_regle = 0; // Definition of $dir and $file if ($object->specimen) @@ -177,7 +177,7 @@ class pdf_azur extends ModelePDFPropales // Create pdf instance $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -262,9 +262,10 @@ class pdf_azur extends ModelePDFPropales for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -379,26 +380,29 @@ class pdf_azur extends ModelePDFPropales // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } // Affiche zone infos $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Affiche zone versements + /* if ($deja_regle) { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); // FIXME not use in proposal? + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } + */ // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); @@ -726,7 +730,7 @@ class pdf_azur extends ModelePDFPropales //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++; @@ -754,7 +758,7 @@ class pdf_azur extends ModelePDFPropales //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++; @@ -795,8 +799,10 @@ class pdf_azur extends ModelePDFPropales $pdf->SetTextColor(0,0,0); - $resteapayer = $object->total_ttc - $deja_regle; // FIXME not use in proposal? - if (! empty($object->paye)) $resteapayer=0; // FIXME not use in proposal? + /* + $resteapayer = $object->total_ttc - $deja_regle; + if (! empty($object->paye)) $resteapayer=0; + */ if ($deja_regle > 0) { @@ -808,7 +814,7 @@ class pdf_azur extends ModelePDFPropales $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); - // FIXME not use in proposal? + /* if ($object->close_code == 'discount_vat') { $index++; @@ -822,6 +828,7 @@ class pdf_azur extends ModelePDFPropales $resteapayer=0; } + */ $index++; $pdf->SetTextColor(0,0,60); 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 7eeddd1f856..058cd1ffab8 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -109,7 +109,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); else { - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt'); + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt','','name',SORT_ASC,0,true); // Disable hook for the moment if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); } } 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 75cd1c17385..d1ef4e3bb27 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -176,7 +176,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $nblignes = count($object->lines); $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -259,9 +259,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -367,13 +368,13 @@ if ($pageposafter > $pageposbefore) { // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } // Affiche zone totaux diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index a0fe3c05aea..dd6109b818b 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -188,7 +188,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $nblignes = count($object->lines); $pdf=pdf_getInstance($this->format); - $heightforinfotot = 80; // Height reserved to output the info and total part (value include bottom margin) + $heightforinfotot = 50; // Height reserved to output the info and total part $heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $pdf->SetAutoPageBreak(1,0); @@ -271,9 +271,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; - $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage - - $pdf->setTopMargin($tab_top_newpage); + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $this->marge_basse+$heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); @@ -328,15 +329,18 @@ if ($pageposafter > $pageposbefore) { $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100; + if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; + if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=''; + if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=''; + if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=''; $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; @@ -381,13 +385,13 @@ if ($pageposafter > $pageposbefore) { // Show square if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot + 1; + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; } // Affiche zone infos @@ -626,7 +630,7 @@ if ($pageposafter > $pageposbefore) { $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1); // Show VAT by rates and total $pdf->SetFillColor(248,248,248); @@ -763,7 +767,7 @@ if ($pageposafter > $pageposbefore) { //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); - if ($object->paye) $resteapayer=0; + if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 78290f896ca..4b079ef78d2 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -329,9 +329,9 @@ $(document).ready(function() { - margin->enabled)) { ?> - $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product; ?>}, function(data) { - if (data.length > 0) { + margin->enabled)) { ?> + $.post('/fourn/ajax/getSupplierPrices.php', {'idprod': fk_product?$line->fk_product:0; ?>}, function(data) { + if (data && data.length > 0) { var options = ''; var trouve=false; $(data).each(function() { diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 49d6ac2926b..e10dc184ccb 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -140,10 +140,12 @@ if (! empty($conf->margin->enabled)) { ?>