From e3853a648f8fd3a475b5d49b8cb69c6e11402d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 25 Feb 2015 19:44:12 +0100 Subject: [PATCH 01/21] Redundant code --- htdocs/margin/admin/margin.php | 3 --- htdocs/projet/admin/project.php | 7 +------ htdocs/societe/admin/societe.php | 5 +---- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index f8beb7cd1ca..b031a190f44 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -72,7 +72,6 @@ if ($action == 'remises') { if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) { - $conf->global->MARGIN_METHODE_FOR_DISCOUNT = $_POST['MARGIN_METHODE_FOR_DISCOUNT']; setEventMessage($langs->trans("RecordModifiedSuccessfully")); } else @@ -85,7 +84,6 @@ if ($action == 'typemarges') { if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { - $conf->global->MARGIN_METHODE_FOR_DISCOUNT = $_POST['MARGIN_TYPE']; setEventMessage($langs->trans("RecordModifiedSuccessfully")); } else @@ -98,7 +96,6 @@ if ($action == 'contact') { if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) { - $conf->global->AGENT_CONTACT_TYPE = $_POST['AGENT_CONTACT_TYPE']; setEventMessage($langs->trans("RecordModifiedSuccessfully")); } else diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 915d4ef69ef..a29bb9a2d63 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -237,12 +237,7 @@ if ($action == 'deltask') // Set default model else if ($action == 'setdoc') { - if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) - { - // La constante qui a ete lue en avant du nouveau set - // on passe donc par une variable pour avoir un affichage coherent - $conf->global->PROJECT_ADDON_PDF = $value; - } + dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity); // On active le modele $ret = delDocumentModel($value, $type); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 8fec81c686c..881946cb1cd 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -165,10 +165,7 @@ if ($action == 'setdoc') $db->begin(); - if (dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) - { - $conf->global->COMPANY_ADDON_PDF = $value; - } + dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity); // On active le modele $type='company'; From f2fededd2c8c6e9d44946d543b086cc3f6763559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 25 Feb 2015 22:48:45 +0100 Subject: [PATCH 02/21] Drop usage of deprecated dol_htmlentities function --- htdocs/admin/security_file.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 10 +++++----- htdocs/main.inc.php | 6 +++--- htdocs/opensurvey/card.php | 12 ++++++------ htdocs/opensurvey/list.php | 4 ++-- htdocs/opensurvey/public/studs.php | 10 +++++----- htdocs/opensurvey/results.php | 14 +++++++------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 4c0dd435634..e70c6116f90 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -176,7 +176,7 @@ if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; print ""; print ''; @@ -187,7 +187,7 @@ print ''.$langs->trans("AntiVirusParam").'
'; print $langs->trans("AntiVirusParamExample"); print ''; print ''; -print ''; +print ''; print ""; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6a6474c8306..edb27913432 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4446,7 +4446,7 @@ class Form $ret.='\n"; + if (! $silent) print '\n"; dol_syslog('Admin.lib::run_sql Request '.($i+1), LOG_DEBUG); $sqlmodified=0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cf3b026ed90..5b57c212150 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -517,7 +517,7 @@ function dol_escape_htmltag($stringtoescape,$keepb=0) $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); if ($keepb) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); else $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n',""=>'',''=>'')); - return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); + return htmlentities($tmp,ENT_COMPAT,'UTF-8'); } @@ -2473,8 +2473,8 @@ function dol_print_error($db='',$error='') } $out.="".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
\n"; $out.="
\n"; - $out.="".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."
\n"; - $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
\n"; + $out.="".$langs->trans("RequestedUrl").": ".htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."
\n"; + $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
\n"; $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
\n"; $out.="
\n"; $syslog.="url=".$_SERVER["REQUEST_URI"]; @@ -3859,13 +3859,13 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$ $newstring=preg_replace('//i','
',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF. if ($removelasteolbr) $newstring=preg_replace('/
$/i','',$newstring); // Remove last
(remove only last one) $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); - $newstring=dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding + $newstring=htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); } else { if ($removelasteolbr) $newstring=preg_replace('/(\r\n|\r|\n)$/i','',$newstring); // Remove last \n (may remove several) - $newstring=dol_nl2br(dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom),$nl2brmode); + $newstring=dol_nl2br(htmlentities($newstring,ENT_COMPAT,$pagecodefrom),$nl2brmode); } // Other substitutions that htmlentities does not do //$newstring=str_replace(chr(128),'€',$newstring); // 128 = 0x80. Not in html entity table. // Seems useles with TCPDF. Make bug with UTF8 languages diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7be99f5e278..ca32a823d58 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -988,9 +988,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $appli='Dolibarr'; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; - if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print ''.dol_htmlentities($title).''; - if ($title) print ''.dol_htmlentities($appli.' - '.$title).''; - else print "".dol_htmlentities($appli).""; + if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print ''.htmlentities($title).''; + if ($title) print ''.htmlentities($appli.' - '.$title).''; + else print "".htmlentities($appli).""; print "\n"; $ext=''; diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 5d32db24d5c..019f739f5fd 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -212,16 +212,16 @@ $adresseadmin=$object->mail_admin; print $langs->trans("Title") .'
'; // Description print ''; @@ -359,7 +359,7 @@ if ($comments) { print ' '.img_picto('', 'delete.png').' '; } - print dol_htmlentities($comment->usercomment).': '.dol_nl2br(dol_htmlentities($comment->comment))."
"; + print htmlentities($comment->usercomment).': '.dol_nl2br(htmlentities($comment->comment))."
"; } } else diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index d13c9884e89..ea17965fa9c 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -153,7 +153,7 @@ while ($i < min($num,$limit)) print ''; print ''; diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php index 1b39391b67c..3050bf0ed08 100644 --- a/htdocs/opensurvey/public/studs.php +++ b/htdocs/opensurvey/public/studs.php @@ -258,7 +258,7 @@ print '
'."\n"; //affichage du titre du sondage $titre=str_replace("\\","",$object->titre); -print ''.dol_htmlentities($titre).'

'."\n"; +print ''.htmlentities($titre).'

'."\n"; //affichage des commentaires du sondage if ($object->commentaires) @@ -362,7 +362,7 @@ if ($object->format=="D") for ($i=0; isset($toutsujet[$i]); $i++) { $heures=explode('@',$toutsujet[$i]); if (isset($heures[1])) { - print '
'."\n"; + print ''."\n"; } else { print ''."\n"; } @@ -418,7 +418,7 @@ while ($compteur < $num) print ''."\n"; // Name - print ''."\n"; + print ''."\n"; // si la ligne n'est pas a changer, on affiche les données if (! $testligneamodifier) @@ -677,7 +677,7 @@ if ($object->allow_spy) { else { $tmps=explode('@',$toutsujet[$i]); - $meilleursujet .= dol_htmlentities($tmps[0]); + $meilleursujet .= htmlentities($tmps[0]); } $compteursujet++; @@ -717,7 +717,7 @@ if ($comments) foreach ($comments as $obj) { print '
'; if (in_array($obj->usercomment, $listofvoters)) print ' '.img_picto('', 'delete.png').' '; - print dol_htmlentities($obj->usercomment).': '.dol_nl2br(dol_htmlentities($obj->comment))."
"; + print htmlentities($obj->usercomment).':'.dol_nl2br(htmlentities($obj->comment)).""; } } diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 226bc0c0465..a543447ffbc 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -451,9 +451,9 @@ $adresseadmin=$object->mail_admin; print $langs->trans("Title") .''; // Expire date @@ -468,7 +468,7 @@ print $langs->trans("Author") .''; @@ -721,7 +721,7 @@ if ($object->format=="D") for ($i = 0; isset($toutsujet[$i]); $i++) { $heures=explode('@', $toutsujet[$i]); if (isset($heures[1])) { - print ''."\n"; + print ''."\n"; } else { print ''."\n"; } @@ -744,7 +744,7 @@ else for ($i = 0; isset($toutsujet[$i]); $i++) { $tmp=explode('@',$toutsujet[$i]); - print ''."\n"; + print ''."\n"; } print ''."\n"; @@ -780,7 +780,7 @@ while ($compteur < $num) } // Name - print ''."\n"; + print ''."\n"; // si la ligne n'est pas a changer, on affiche les données if (! $testligneamodifier) @@ -1047,7 +1047,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { else { $tmps=explode('@',$toutsujet[$i]); - $meilleursujet .= dol_htmlentities($tmps[0]); + $meilleursujet .= htmlentities($tmps[0]); } $compteursujet++; From f117b65a1773c652fe824182f7534981617f9834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 25 Feb 2015 23:00:43 +0100 Subject: [PATCH 03/21] Removed silent operator for PHP 4 in function dol_html_entity_decode --- htdocs/core/lib/functions.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5b57c212150..6f21e9d2202 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3911,9 +3911,7 @@ function dol_htmlcleanlastbr($stringtodecode) */ function dol_html_entity_decode($a,$b,$c='UTF-8') { - // We use @ to avoid warning on PHP4 that does not support entity decoding to UTF8; - $ret=@html_entity_decode($a,$b,$c); - return $ret; + return html_entity_decode($a,$b,$c); } /** From e6c8cac3815a89c6731195f9a5fe52ad59e5d270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 01:16:35 +0100 Subject: [PATCH 04/21] Removed TODO and deprecated tag of dol_htmlentities and revert substitution commit --- htdocs/admin/security_file.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 12 +++++------- htdocs/main.inc.php | 6 +++--- htdocs/opensurvey/card.php | 12 ++++++------ htdocs/opensurvey/list.php | 4 ++-- htdocs/opensurvey/public/studs.php | 10 +++++----- htdocs/opensurvey/results.php | 14 +++++++------- 9 files changed, 32 insertions(+), 34 deletions(-) diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index e70c6116f90..4c0dd435634 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -176,7 +176,7 @@ if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; print ""; print ''; @@ -187,7 +187,7 @@ print ''; print '"; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index edb27913432..6a6474c8306 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4446,7 +4446,7 @@ class Form $ret.='
'; } - $ret.=dol_htmlentities($object->$fieldref); + $ret.=htmlentities($object->$fieldref); if ($morehtmlref) { $ret.=' '.$morehtmlref; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index a54cb5fcc79..54f2748cfd1 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -249,7 +249,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker $newsql=preg_replace('/__ENTITY__/i',(!empty($entity)?$entity:$conf->entity),$sql); // Ajout trace sur requete (eventuellement a commenter si beaucoup de requetes) - if (! $silent) print '
'.$langs->trans("Request").' '.($i+1)." sql='".dol_htmlentities($newsql,ENT_NOQUOTES)."'
'.$langs->trans("Request").' '.($i+1)." sql='".htmlentities($newsql,ENT_NOQUOTES)."'
'; if ($action == 'edit') { - print ''; + print ''; } -else print dol_htmlentities($object->titre); +else print htmlentities($object->titre); print '
'.$langs->trans("Description") .''; if ($action == 'edit') { - $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); + $doleditor=new DolEditor('nouveauxcommentaires', htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); $doleditor->Create(0,''); } else @@ -229,7 +229,7 @@ else if (empty($conf->fckeditor->enabled)) print dol_htmlentitiesbr($object->commentaires); else { - $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120,1); + $doleditor=new DolEditor('nouveauxcommentaires', htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120,1); $doleditor->Create(0,''); } } @@ -295,7 +295,7 @@ print $langs->trans("Author") .''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { - print dol_htmlentities($object->nom_admin); + print htmlentities($object->nom_admin); } print '
'; print ''.img_picto('','object_opensurvey').' '.$obj->id_sondage.''; - print ''.dol_htmlentities($obj->titre).''; + print ''.htmlentities($obj->titre).''; $type=($obj->format=='A')?'classic':'date'; print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1); print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); @@ -169,7 +169,7 @@ while ($i < min($num,$limit)) print $userstatic->getLoginUrl(1); } else { - print dol_htmlentities($obj->nom_admin); + print htmlentities($obj->nom_admin); } print ''.dol_htmlentities($heures[1]).''.htmlentities($heures[1]).'
'.dol_htmlentities($obj->name).''.htmlentities($obj->name).' '; if ($action == 'edit') { - print ''; + print ''; } -else print dol_htmlentities($object->titre); +else print htmlentities($object->titre); print '
'; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { - print dol_htmlentities($object->nom_admin); + print htmlentities($object->nom_admin); } print '
'.dol_htmlentities($heures[1]).''.htmlentities($heures[1]).''.dol_htmlentities($tmp[0]).''.htmlentities($tmp[0]).''.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).''.dol_htmlentities($obj->name).''.htmlentities($obj->name).'
'.$langs->trans("AntiVirusParam").'
'; print $langs->trans("AntiVirusParamExample"); print '
'; -print ''; +print ''; print "
\n"; + if (! $silent) print '\n"; dol_syslog('Admin.lib::run_sql Request '.($i+1), LOG_DEBUG); $sqlmodified=0; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6f21e9d2202..fdfb20dd558 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -517,7 +517,7 @@ function dol_escape_htmltag($stringtoescape,$keepb=0) $tmp=dol_html_entity_decode($stringtoescape,ENT_COMPAT,'UTF-8'); if ($keepb) $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n')); else $tmp=strtr($tmp, array("\r"=>'\\r',"\n"=>'\\n',""=>'',''=>'')); - return htmlentities($tmp,ENT_COMPAT,'UTF-8'); + return dol_htmlentities($tmp,ENT_COMPAT,'UTF-8'); } @@ -2473,8 +2473,8 @@ function dol_print_error($db='',$error='') } $out.="".$langs->trans("UserAgent").": ".$_SERVER["HTTP_USER_AGENT"]."
\n"; $out.="
\n"; - $out.="".$langs->trans("RequestedUrl").": ".htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."
\n"; - $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
\n"; + $out.="".$langs->trans("RequestedUrl").": ".dol_htmlentities($_SERVER["REQUEST_URI"],ENT_COMPAT,'UTF-8')."
\n"; + $out.="".$langs->trans("Referer").": ".(isset($_SERVER["HTTP_REFERER"])?dol_htmlentities($_SERVER["HTTP_REFERER"],ENT_COMPAT,'UTF-8'):'')."
\n"; $out.="".$langs->trans("MenuManager").": ".(isset($conf->standard_menu)?$conf->standard_menu:'')."
\n"; $out.="
\n"; $syslog.="url=".$_SERVER["REQUEST_URI"]; @@ -3859,13 +3859,13 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$ $newstring=preg_replace('//i','
',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF. if ($removelasteolbr) $newstring=preg_replace('/
$/i','',$newstring); // Remove last
(remove only last one) $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__')); - $newstring=htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding + $newstring=dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); } else { if ($removelasteolbr) $newstring=preg_replace('/(\r\n|\r|\n)$/i','',$newstring); // Remove last \n (may remove several) - $newstring=dol_nl2br(htmlentities($newstring,ENT_COMPAT,$pagecodefrom),$nl2brmode); + $newstring=dol_nl2br(dol_htmlentities($newstring,ENT_COMPAT,$pagecodefrom),$nl2brmode); } // Other substitutions that htmlentities does not do //$newstring=str_replace(chr(128),'€',$newstring); // 128 = 0x80. Not in html entity table. // Seems useles with TCPDF. Make bug with UTF8 languages @@ -3917,14 +3917,12 @@ function dol_html_entity_decode($a,$b,$c='UTF-8') /** * Replace htmlentities functions to manage errors * http://php.net/manual/en/function.htmlentities.php - * TODO Remove this function to replace it with direct htmlentities. * * @param string $string The input string. * @param int $flags Flags(see PHP doc above) * @param string $encoding Encoding * @param bool $double_encode When double_encode is turned off PHP will not encode existing html entities * @return string $ret Encoded string - * @deprecated Since PHP4 support is no longer available, this function does not make sense. */ function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ca32a823d58..7be99f5e278 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -988,9 +988,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs $appli='Dolibarr'; if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; - if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print ''.htmlentities($title).''; - if ($title) print ''.htmlentities($appli.' - '.$title).''; - else print "".htmlentities($appli).""; + if ($title && ! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/',$conf->global->MAIN_HTML_TITLE)) print ''.dol_htmlentities($title).''; + if ($title) print ''.dol_htmlentities($appli.' - '.$title).''; + else print "".dol_htmlentities($appli).""; print "\n"; $ext=''; diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 019f739f5fd..5d32db24d5c 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -212,16 +212,16 @@ $adresseadmin=$object->mail_admin; print $langs->trans("Title") .'
'; // Description print ''; @@ -359,7 +359,7 @@ if ($comments) { print ' '.img_picto('', 'delete.png').' '; } - print htmlentities($comment->usercomment).': '.dol_nl2br(htmlentities($comment->comment))."
"; + print dol_htmlentities($comment->usercomment).': '.dol_nl2br(dol_htmlentities($comment->comment))."
"; } } else diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index ea17965fa9c..d13c9884e89 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -153,7 +153,7 @@ while ($i < min($num,$limit)) print ''; print ''; diff --git a/htdocs/opensurvey/public/studs.php b/htdocs/opensurvey/public/studs.php index 3050bf0ed08..1b39391b67c 100644 --- a/htdocs/opensurvey/public/studs.php +++ b/htdocs/opensurvey/public/studs.php @@ -258,7 +258,7 @@ print '
'."\n"; //affichage du titre du sondage $titre=str_replace("\\","",$object->titre); -print ''.htmlentities($titre).'

'."\n"; +print ''.dol_htmlentities($titre).'

'."\n"; //affichage des commentaires du sondage if ($object->commentaires) @@ -362,7 +362,7 @@ if ($object->format=="D") for ($i=0; isset($toutsujet[$i]); $i++) { $heures=explode('@',$toutsujet[$i]); if (isset($heures[1])) { - print '
'."\n"; + print ''."\n"; } else { print ''."\n"; } @@ -418,7 +418,7 @@ while ($compteur < $num) print ''."\n"; // Name - print ''."\n"; + print ''."\n"; // si la ligne n'est pas a changer, on affiche les données if (! $testligneamodifier) @@ -677,7 +677,7 @@ if ($object->allow_spy) { else { $tmps=explode('@',$toutsujet[$i]); - $meilleursujet .= htmlentities($tmps[0]); + $meilleursujet .= dol_htmlentities($tmps[0]); } $compteursujet++; @@ -717,7 +717,7 @@ if ($comments) foreach ($comments as $obj) { print '
'; if (in_array($obj->usercomment, $listofvoters)) print ' '.img_picto('', 'delete.png').' '; - print htmlentities($obj->usercomment).': '.dol_nl2br(htmlentities($obj->comment))."
"; + print dol_htmlentities($obj->usercomment).':'.dol_nl2br(dol_htmlentities($obj->comment)).""; } } diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index a543447ffbc..226bc0c0465 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -451,9 +451,9 @@ $adresseadmin=$object->mail_admin; print $langs->trans("Title") .''; // Expire date @@ -468,7 +468,7 @@ print $langs->trans("Author") .''; @@ -721,7 +721,7 @@ if ($object->format=="D") for ($i = 0; isset($toutsujet[$i]); $i++) { $heures=explode('@', $toutsujet[$i]); if (isset($heures[1])) { - print ''."\n"; + print ''."\n"; } else { print ''."\n"; } @@ -744,7 +744,7 @@ else for ($i = 0; isset($toutsujet[$i]); $i++) { $tmp=explode('@',$toutsujet[$i]); - print ''."\n"; + print ''."\n"; } print ''."\n"; @@ -780,7 +780,7 @@ while ($compteur < $num) } // Name - print ''."\n"; + print ''."\n"; // si la ligne n'est pas a changer, on affiche les données if (! $testligneamodifier) @@ -1047,7 +1047,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { else { $tmps=explode('@',$toutsujet[$i]); - $meilleursujet .= htmlentities($tmps[0]); + $meilleursujet .= dol_htmlentities($tmps[0]); } $compteursujet++; From ad7242529111062f5873b234cba7354555c03863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 03:27:29 +0100 Subject: [PATCH 05/21] Moved some variables from FactureLigne to CommonInvoiceLine --- htdocs/compta/facture/class/facture.class.php | 35 ------- htdocs/core/class/commoninvoice.class.php | 95 +++++++++++++++++++ 2 files changed, 95 insertions(+), 35 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4fbdddd5703..d9254df2374 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3586,16 +3586,12 @@ class Facture extends CommonInvoice */ class FactureLigne extends CommonInvoiceLine { - var $db; - var $error; - public $element='facturedet'; public $table_element='facturedet'; var $oldline; //! From llx_facturedet - var $rowid; //! Id facture var $fk_facture; //! Id parent line @@ -3603,17 +3599,9 @@ class FactureLigne extends CommonInvoiceLine var $label; // deprecated //! Description ligne var $desc; - var $fk_product; // Id of predefined product - var $product_type = 0; // Type 0 = product, 1 = Service - var $qty; // Quantity (example 2) - var $tva_tx; // Taux tva produit/service (example 19.6) - var $localtax1_tx; // Local tax 1 - var $localtax2_tx; // Local tax 2 var $localtax1_type; // Local tax 1 type var $localtax2_type; // Local tax 2 type - var $subprice; // P.U. HT (example 100) - var $remise_percent; // % de la remise ligne (example 20%) var $fk_remise_except; // Link to line into llx_remise_except var $rang = 0; @@ -3622,10 +3610,6 @@ class FactureLigne extends CommonInvoiceLine var $marge_tx; var $marque_tx; - var $info_bits = 0; // Liste d'options cumulables: - // Bit 0: 0 si TVA normal - 1 si TVA NPR - // Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) - var $special_code; // Liste d'options non cumulabels: // 1: frais de port // 2: ecotaxe @@ -3634,15 +3618,6 @@ class FactureLigne extends CommonInvoiceLine var $origin; var $origin_id; - //! Total HT de la ligne toute quantite et incluant la remise ligne - var $total_ht; - //! Total TVA de la ligne toute quantite et incluant la remise ligne - var $total_tva; - var $total_localtax1; //Total Local tax 1 de la ligne - var $total_localtax2; //Total Local tax 2 de la ligne - //! Total TTC de la ligne toute quantite et incluant la remise ligne - var $total_ttc; - var $fk_code_ventilation = 0; var $date_start; @@ -3671,16 +3646,6 @@ class FactureLigne extends CommonInvoiceLine */ public $fk_prev_id; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } - /** * Load invoice line from database * diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 6087a5a0adb..1a7ebfc34c8 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -400,5 +400,100 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; */ abstract class CommonInvoiceLine extends CommonObjectLine { + /** + * Quantity + * @var int + */ + public $qty; + + /** + * Unit price before taxes + * @var float + */ + public $subprice; + + /** + * Type of the product. 0 for product 1 for service + * @var int + */ + public $product_type = 0; + + /** + * Id of corresponding product + * @var int + */ + public $fk_product; + + /** + * VAT % + * @var float + */ + public $tva_tx; + + /** + * Local tax 1 % + * @var float + */ + public $localtax1_tx; + + /** + * Local tax 2 % + * @var float + */ + public $localtax2_tx; + + /** + * Percent of discount + * @var float + */ + public $remise_percent; + + /** + * Total amount before taxes + * @var float + */ + public $total_ht; + + /** + * Total VAT amount + * @var float + */ + public $total_tva; + + /** + * Total local tax 1 amount + * @var float + */ + public $total_localtax1; + + /** + * Total local tax 2 amount + * @var float + */ + public $total_localtax2; + + /** + * Total amount with taxes + * @var float + */ + public $total_ttc; + + /** + * Liste d'options cumulables: + * Bit 0: 0 si TVA normal - 1 si TVA NPR + * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) + * @var int + */ + public $info_bits = 0; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + } } From c7919a8d08bded53a302c4635ee55de5e4c31c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 03:27:48 +0100 Subject: [PATCH 06/21] Removed duplicated code --- .../fourn/class/fournisseur.facture.class.php | 33 +++---------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 8283f1cb957..a152b1a2b2c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -89,37 +89,15 @@ class FactureFournisseur extends CommonInvoice var $mode_reglement_id; var $mode_reglement_code; - var $lines; + /** + * Invoice lines + * @var SupplierInvoiceLine[] + */ + public $lines = array(); var $fournisseur; // deprecated - var $thirdparty; // To store thirdparty var $extraparams=array(); - /** - * Standard invoice - */ - const TYPE_STANDARD = 0; - - /** - * Replacement invoice - */ - const TYPE_REPLACEMENT = 1; - - /** - * Credit note invoice - */ - const TYPE_CREDIT_NOTE = 2; - - /** - * Deposit invoice - */ - const TYPE_DEPOSIT = 3; - - /** - * Proforma invoice - */ - const TYPE_PROFORMA = 4; - /** * Constructor * @@ -140,7 +118,6 @@ class FactureFournisseur extends CommonInvoice $this->propalid = 0; $this->products = array(); - $this->lines = array(); } /** From b0e728251a1ffa5b35b747d929ca4e76be74e40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 03:28:08 +0100 Subject: [PATCH 07/21] Every line has a $rowid property --- htdocs/core/class/commonobjectline.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index c3c8d823a34..7f81c85fa23 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -28,6 +28,12 @@ */ abstract class CommonObjectLine extends CommonObject { + /** + * Id of the line + * @var int + */ + public $rowid; + // TODO // Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code. From b69ce21e3e271e6691bc17d163b1295f99744e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 03:52:59 +0100 Subject: [PATCH 08/21] Removed duplicated code --- htdocs/comm/propal/class/propal.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 189c6101594..4918e331d63 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -107,6 +107,9 @@ class Propal extends CommonObject var $products=array(); var $extraparams=array(); + /** + * @var PropaleLigne[] + */ var $lines = array(); var $line; @@ -2782,9 +2785,6 @@ class Propal extends CommonObject */ class PropaleLigne extends CommonObject { - var $db; - var $error; - public $element='propaldet'; public $table_element='propaldet'; From 4c08d34bb5332d42678a37d482007faa436569d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 03:53:12 +0100 Subject: [PATCH 09/21] Standardized $rowid as property --- htdocs/commande/class/commande.class.php | 1 + htdocs/compta/facture/class/facture.class.php | 1 + htdocs/core/class/commonobject.class.php | 6 +++--- htdocs/core/class/commonobjectline.class.php | 7 +++++++ htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- htdocs/core/tpl/objectline_view.tpl.php | 12 ++++++------ htdocs/fichinter/class/fichinter.class.php | 1 - 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c1c0fa9ec4e..01de7890f9b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3141,6 +3141,7 @@ class Commande extends CommonOrder $this->lines[$i] = new OrderLine($this->db); $this->lines[$i]->id = $obj->rowid; + $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d9254df2374..72801b121ff 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3388,6 +3388,7 @@ class Facture extends CommonInvoice $this->lines[$i] = new FactureLigne($this->db); $this->lines[$i]->id = $obj->rowid; + $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->label = $obj->custom_label; // deprecated $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c4b2902113a..c08a2b449d7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2671,7 +2671,7 @@ abstract class CommonObject * TODO Move this into an output class file (htmlline.class.php) * * @param string $action GET/POST action - * @param array $line Selected object line to output + * @param CommonObjectLine $line Selected object line to output * @param string $var Is it a an odd line (true) * @param int $num Number of line (0) * @param int $i I @@ -2699,7 +2699,7 @@ abstract class CommonObject if (! empty($line->date_end)) $type=1; // deprecated // Ligne en mode visu - if ($action != 'editline' || $selected != $line->id) + if ($action != 'editline' || $selected != $line->rowid) { // Product if ($line->fk_product > 0) @@ -2762,7 +2762,7 @@ abstract class CommonObject } // Ligne en mode update - if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) + if ($this->statut == 0 && $action == 'editline' && $selected == $line->rowid) { $label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 7f81c85fa23..b88dfabe83d 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -28,6 +28,13 @@ */ abstract class CommonObjectLine extends CommonObject { + /** + * Id of the line + * @var int + * @deprecated Use $rowid + */ + public $id; + /** * Id of the line * @var int diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 98f1b842f1a..6148d50f6fc 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -53,9 +53,9 @@ $coldisplay=-1; // We remove first td ?> > global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>global->MAIN_VIEW_LINE_NUMBER))?2:1; ?> -
+
- + diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 0664d471dec..3ae8a8bcaa4 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -44,11 +44,11 @@ if (empty($usemargins)) $usemargins=0; ?> -
> +> global->MAIN_VIEW_LINE_NUMBER)) { ?> - - + @@ -173,7 +173,7 @@ if (empty($usemargins)) $usemargins=0; - statut == 0 && ($user->rights->$element->creer || $permtoedit)) { ?> + statut == 0 && ($object_rights->creer)) { ?>
'; } - $ret.=htmlentities($object->$fieldref); + $ret.=dol_htmlentities($object->$fieldref); if ($morehtmlref) { $ret.=' '.$morehtmlref; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 54f2748cfd1..a54cb5fcc79 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -249,7 +249,7 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$oker $newsql=preg_replace('/__ENTITY__/i',(!empty($entity)?$entity:$conf->entity),$sql); // Ajout trace sur requete (eventuellement a commenter si beaucoup de requetes) - if (! $silent) print '
'.$langs->trans("Request").' '.($i+1)." sql='".htmlentities($newsql,ENT_NOQUOTES)."'
'.$langs->trans("Request").' '.($i+1)." sql='".dol_htmlentities($newsql,ENT_NOQUOTES)."'
'; if ($action == 'edit') { - print ''; + print ''; } -else print htmlentities($object->titre); +else print dol_htmlentities($object->titre); print '
'.$langs->trans("Description") .''; if ($action == 'edit') { - $doleditor=new DolEditor('nouveauxcommentaires', htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); + $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120); $doleditor->Create(0,''); } else @@ -229,7 +229,7 @@ else if (empty($conf->fckeditor->enabled)) print dol_htmlentitiesbr($object->commentaires); else { - $doleditor=new DolEditor('nouveauxcommentaires', htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120,1); + $doleditor=new DolEditor('nouveauxcommentaires', dol_htmlentities($object->commentaires),'',120,'dolibarr_notes','In',1,1,1,ROWS_7,120,1); $doleditor->Create(0,''); } } @@ -295,7 +295,7 @@ print $langs->trans("Author") .''; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { - print htmlentities($object->nom_admin); + print dol_htmlentities($object->nom_admin); } print '
'; print ''.img_picto('','object_opensurvey').' '.$obj->id_sondage.''; - print ''.htmlentities($obj->titre).''; + print ''.dol_htmlentities($obj->titre).''; $type=($obj->format=='A')?'classic':'date'; print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1); print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); @@ -169,7 +169,7 @@ while ($i < min($num,$limit)) print $userstatic->getLoginUrl(1); } else { - print htmlentities($obj->nom_admin); + print dol_htmlentities($obj->nom_admin); } print ''.htmlentities($heures[1]).''.dol_htmlentities($heures[1]).'
'.htmlentities($obj->name).''.dol_htmlentities($obj->name).' '; if ($action == 'edit') { - print ''; + print ''; } -else print htmlentities($object->titre); +else print dol_htmlentities($object->titre); print '
'; if ($object->fk_user_creat) { print $userstatic->getLoginUrl(1); } else { - print htmlentities($object->nom_admin); + print dol_htmlentities($object->nom_admin); } print '
'.htmlentities($heures[1]).''.dol_htmlentities($heures[1]).''.htmlentities($tmp[0]).''.dol_htmlentities($tmp[0]).''.img_picto('',dol_buildpath('/opensurvey/img/add-16.png',1),'',1).''.htmlentities($obj->name).''.dol_htmlentities($obj->name).'
+
info_bits & 2) == 2) { ?> info_bits & 2) == 2) { ?> - id.'#'.$line->id; ?>"> + rowid.'#'.$line->rowid; ?>"> @@ -186,7 +186,7 @@ if (empty($usemargins)) $usemargins=0;
situation_counter == 1 || !$this->situation_cycle_ref) { - print 'id . '">'; + print 'rowid . '">'; print img_delete(); print ''; } @@ -196,12 +196,12 @@ if (empty($usemargins)) $usemargins=0; 1 && empty($conf->browser->phone) && ($this->situation_counter == 1 || !$this->situation_cycle_ref)) { ?> 0) { ?> - id; ?>"> + rowid; ?>"> - id; ?>"> + rowid; ?>"> diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 7be3b0bf3bd..e98852685ad 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1022,7 +1022,6 @@ class FichinterLigne extends CommonObjectLine var $error; // From llx_fichinterdet - var $rowid; var $fk_fichinter; var $desc; // Description ligne var $datei; // Date intervention From b84cf4afac89ab6c5112c5edf94c3a4f85bcbfcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:21:20 +0100 Subject: [PATCH 10/21] Renamed FactureFournisseurLine to SupplierInvoiceLine --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8a98ac2f613..6481a5961ca 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -281,7 +281,7 @@ else { $newline = new CommandeFournisseurLigne($this->db); } elseif ($this->table_element_line=='facture_fourn_det') { - $newline = new FactureFournisseurLigne($this->db); + $newline = new SupplierInvoiceLine($this->db); } if (is_object($newline)) { print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a152b1a2b2c..c6e5cb9d5e6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -478,7 +478,7 @@ class FactureFournisseur extends CommonInvoice { $obj = $this->db->fetch_object($resql_rows); - $this->lines[$i] = new FactureFournisseurLigne($this->db); + $this->lines[$i] = new SupplierInvoiceLine($this->db); $this->lines[$i]->id = $obj->rowid; $this->lines[$i]->rowid = $obj->rowid; @@ -1274,7 +1274,7 @@ class FactureFournisseur extends CommonInvoice if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $linetmp = new FactureFournisseurLigne($this->db); + $linetmp = new SupplierInvoiceLine($this->db); $linetmp->id=$this->rowid; $linetmp->array_options = $array_options; $result=$linetmp->insertExtraFields(); @@ -1826,7 +1826,7 @@ class FactureFournisseur extends CommonInvoice /** * Class to manage line invoices */ -class FactureFournisseurLigne extends CommonInvoice +class SupplierInvoiceLine extends CommonInvoice { var $db; var $error; From 47a151f1572509362b556772520648aa2253e4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:23:18 +0100 Subject: [PATCH 11/21] Created supplier invoice line --- .../fourn/class/fournisseur.facture.class.php | 85 ++++++++++++++++--- 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c6e5cb9d5e6..22f3c02a5a1 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -457,7 +457,7 @@ class FactureFournisseur extends CommonInvoice */ function fetch_lines() { - $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; + $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx'; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; @@ -488,6 +488,7 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline $this->lines[$i]->libelle = $obj->label; // This field may contains label of product (when invoice create from order) $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit + $this->lines[$i]->subprice = $obj->pu_ht; $this->lines[$i]->pu_ht = $obj->pu_ht; $this->lines[$i]->pu_ttc = $obj->pu_ttc; $this->lines[$i]->tva_tx = $obj->tva_tx; @@ -495,7 +496,7 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; $this->lines[$i]->qty = $obj->qty; $this->lines[$i]->remise_percent = $obj->remise_percent; - $this->lines[$i]->tva = $obj->tva; + $this->lines[$i]->tva = $obj->total_tva; $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_localtax1 = $obj->total_localtax1; @@ -1819,6 +1820,18 @@ class FactureFournisseur extends CommonInvoice return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + /** + * Returns the rights used for this class + * @return stdClass + */ + public function getRights() + { + global $user; + + return $user->rights->fournisseur->facture; + } + + } @@ -1828,18 +1841,68 @@ class FactureFournisseur extends CommonInvoice */ class SupplierInvoiceLine extends CommonInvoice { - var $db; - var $error; - - var $pu_ht; - var $pu_ttc; - - public $element='facture_fourn_det'; + public $element='fournisseur->facture'; public $table_element='facture_fourn_det'; - var $oldline; + var $oldline; - /** + public $ref; + public $product_ref; + public $ref_supplier; + public $libelle; + public $product_desc; + + /** + * Unit price before taxes + * @var float + * @deprecated Use $subprice + */ + public $pu_ht; + + /** + * Unit price included taxes + * @var float + */ + public $pu_ttc; + + /** + * Total VAT amount + * @var float + * @deprecated Use $total_tva instead + */ + public $tva; + + /** + * Id of the corresponding supplier invoice + * @var int + */ + var $fk_facture_fourn; + + /** + * Product label + * @var string + */ + var $label; // deprecated + + /** + * Description of the line + * @var string + */ + var $description; + + var $skip_update_total; // Skip update price total for special lines + + /** + * @var int Situation advance percentage + */ + public $situation_percent; + + /** + * @var int Previous situation line id reference + */ + public $fk_prev_id; + + /** * Constructor * * @param DoliDB $db Database handler From 174f1cb5f7607407ff60a8d52898d1ff0b369efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:28:37 +0100 Subject: [PATCH 12/21] Refactored supplier invoice line view to fit commonobjectline view --- htdocs/core/class/commonobject.class.php | 16 +++++++++++++++- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c08a2b449d7..523716a8c84 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2686,7 +2686,9 @@ abstract class CommonObject function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0,$permtoedit=0) { global $conf,$langs,$user,$object,$hookmanager; - global $form,$bc,$bcdd; + global $form,$bc,$bcdd, $object_rights; + + $object_rights = $this->getRights(); $element=$this->element; @@ -3727,4 +3729,16 @@ abstract class CommonObject return $out; } + /** + * Returns the rights used for this class + * @return stdClass + */ + public function getRights() + { + global $user; + + return $user->rights->{$this->element}; + } + + } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 3ae8a8bcaa4..2203642f0dc 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -122,7 +122,7 @@ if (empty($usemargins)) $usemargins=0; tva_tx,'%',$line->info_bits); ?>pu_ht)?price($line->pu_ht):price($line->subprice)); ?>pu_ht); ?> pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?>total_ht); ?> info_bits & 2) == 2) { ?> From f82df1e634e67db455dd21ea722739a6eabd9825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:32:09 +0100 Subject: [PATCH 13/21] Refactorred supplier order to match with objectline templates --- htdocs/core/class/commonorder.class.php | 3 +- .../class/fournisseur.commande.class.php | 128 +++++++++++++++--- 2 files changed, 108 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 469e1676a53..3e30b0a9ca6 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -22,6 +22,7 @@ */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php'; /** * \class CommonOrder @@ -36,7 +37,7 @@ abstract class CommonOrder extends CommonObject * \class CommonOrderLine * \brief Superclass for orders classes */ -abstract class CommonOrderLine extends CommonObject +abstract class CommonOrderLine extends CommonObjectLine { } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e626760f83e..3d4bfd7fb90 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -88,8 +88,12 @@ class CommandeFournisseur extends CommonOrder var $extraparams=array(); + /** + * @var CommandeFournisseurLigne[] + */ + public $lines = array(); - /** + /** * Constructor * * @param DoliDB $db Database handler @@ -98,7 +102,6 @@ class CommandeFournisseur extends CommonOrder { $this->db = $db; $this->products = array(); - $this->lines = array(); // List of language codes for status $this->statuts[0] = 'StatusOrderDraft'; @@ -237,6 +240,7 @@ class CommandeFournisseur extends CommonOrder $line = new CommandeFournisseurLigne($this->db); $line->id = $objp->rowid; + $line->rowid = $objp->rowid; $line->desc = $objp->description; // Description ligne $line->description = $objp->description; // Description ligne $line->qty = $objp->qty; @@ -2206,6 +2210,18 @@ class CommandeFournisseur extends CommonOrder if ($nb === 0) return $langs->trans('Undefined'); else return $nb.' '.$langs->trans('Days'); } + + /** + * Returns the rights used for this class + * @return stdClass + */ + public function getRights() + { + global $user; + + return $user->rights->fournisseur->commande; + } + } @@ -2221,27 +2237,95 @@ class CommandeFournisseurLigne extends CommonOrderLine public $element='commande_fournisseurdet'; public $table_element='commande_fournisseurdet'; - var $oldline; + /** + * Quantity + * @var int + */ - // From llx_commandedet - var $qty; - var $tva_tx; - var $localtax1_tx; - var $localtax2_tx; - var $localtax1_type; - var $localtax2_type; - var $subprice; - var $remise_percent; - var $desc; // Description ligne - var $fk_product; // Id of predefined product - var $product_type = 0; // Type 0 = product, 1 = Service - var $total_ht; - var $total_tva; - var $total_localtax1; - var $total_localtax2; - var $total_ttc; - var $info_bits; - var $special_code; + /** + * Unit price before taxes + * @var float + */ + public $subprice; + + /** + * Type of the product. 0 for product 1 for service + * @var int + */ + public $product_type = 0; + + /** + * Description of the line + * @var string + */ + var $desc; + + /** + * Id of corresponding product + * @var int + */ + public $fk_product; + + /** + * VAT % + * @var float + */ + public $tva_tx; + + /** + * Local tax 1 % + * @var float + */ + public $localtax1_tx; + + /** + * Local tax 2 % + * @var float + */ + public $localtax2_tx; + + var $localtax1_type; + var $localtax2_type; + + /** + * Total amount before taxes + * @var float + */ + public $total_ht; + + /** + * Total VAT amount + * @var float + */ + public $total_tva; + + /** + * Total local tax 1 amount + * @var float + */ + public $total_localtax1; + + /** + * Total local tax 2 amount + * @var float + */ + public $total_localtax2; + + /** + * Total amount with taxes + * @var float + */ + public $total_ttc; + + /** + * Liste d'options cumulables: + * Bit 0: 0 si TVA normal - 1 si TVA NPR + * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) + * @var int + */ + public $info_bits = 0; + + var $special_code; var $date_start; var $date_end; From e1982c54d9cf64b7458717757f4453b4f6b0ec59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:34:19 +0100 Subject: [PATCH 14/21] Moved duplicated code to common class --- htdocs/commande/class/commande.class.php | 60 ++++++------ htdocs/core/class/commonorder.class.php | 96 +++++++++++++++++++ .../class/fournisseur.commande.class.php | 92 ------------------ 3 files changed, 125 insertions(+), 123 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 01de7890f9b..cdf73d58c7e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -104,7 +104,10 @@ class Commande extends CommonOrder var $user_author_id; - var $lines = array(); + /** + * @var OrderLine[] + */ + var $lines = array(); /** @@ -3228,54 +3231,49 @@ class Commande extends CommonOrder */ class OrderLine extends CommonOrderLine { - var $db; - var $error; - public $element='commandedet'; public $table_element='commandedet'; var $oldline; // From llx_commandedet - var $rowid; var $fk_parent_line; var $fk_facture; var $label; - var $desc; // Description ligne - var $fk_product; // Id produit predefini - var $product_type = 0; // Type 0 = product, 1 = Service - - var $qty; // Quantity (example 2) - var $tva_tx; // VAT Rate for product/service (example 19.6) - var $localtax1_tx; // Local tax 1 - var $localtax2_tx; // Local tax 2 - var $localtax1_type; // Local tax 1 type - var $localtax2_type; // Local tax 2 type - 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; + + /** + * Buy price without taxes + * @var float + */ 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 - 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 - var $total_localtax2; // Total local tax 2 for the line - var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - // Ne plus utiliser - var $remise; - var $price; + /** + * @deprecated + */ + var $remise; + + /** + * @deprecated + */ + var $price; // From llx_product - var $ref; // deprecated - var $libelle; // deprecated - var $product_ref; + /** + * @deprecated Use product_ref + */ + var $ref; + + /** + * @deprecated Use product_label + */ + var $libelle; + + var $product_ref; var $product_label; // Label produit var $product_desc; // Description produit diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 3e30b0a9ca6..eadf34d5583 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -39,6 +39,102 @@ abstract class CommonOrder extends CommonObject */ abstract class CommonOrderLine extends CommonObjectLine { + /** + * Quantity + * @var int + */ + public $qty; + + /** + * Unit price before taxes + * @var float + */ + public $subprice; + + /** + * Type of the product. 0 for product 1 for service + * @var int + */ + public $product_type = 0; + + /** + * Description of the line + * @var string + */ + public $desc; + + /** + * Id of corresponding product + * @var int + */ + public $fk_product; + + /** + * Percent line discount + * @var float + */ + public $remise_percent; + + /** + * VAT % + * @var float + */ + public $tva_tx; + + /** + * Local tax 1 % + * @var float + */ + public $localtax1_tx; + + /** + * Local tax 2 % + * @var float + */ + public $localtax2_tx; + + public $localtax1_type; + public $localtax2_type; + + /** + * Total amount before taxes + * @var float + */ + public $total_ht; + + /** + * Total VAT amount + * @var float + */ + public $total_tva; + + /** + * Total local tax 1 amount + * @var float + */ + public $total_localtax1; + + /** + * Total local tax 2 amount + * @var float + */ + public $total_localtax2; + + /** + * Total amount with taxes + * @var float + */ + public $total_ttc; + + /** + * Liste d'options cumulables: + * Bit 0: 0 si TVA normal - 1 si TVA NPR + * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) + * @var int + */ + public $info_bits = 0; + + public $special_code = 0; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3d4bfd7fb90..bc2e1e564b2 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2231,101 +2231,9 @@ class CommandeFournisseur extends CommonOrder */ class CommandeFournisseurLigne extends CommonOrderLine { - var $db; - var $error; - public $element='commande_fournisseurdet'; public $table_element='commande_fournisseurdet'; - /** - * Quantity - * @var int - */ - - /** - * Unit price before taxes - * @var float - */ - public $subprice; - - /** - * Type of the product. 0 for product 1 for service - * @var int - */ - public $product_type = 0; - - /** - * Description of the line - * @var string - */ - var $desc; - - /** - * Id of corresponding product - * @var int - */ - public $fk_product; - - /** - * VAT % - * @var float - */ - public $tva_tx; - - /** - * Local tax 1 % - * @var float - */ - public $localtax1_tx; - - /** - * Local tax 2 % - * @var float - */ - public $localtax2_tx; - - var $localtax1_type; - var $localtax2_type; - - /** - * Total amount before taxes - * @var float - */ - public $total_ht; - - /** - * Total VAT amount - * @var float - */ - public $total_tva; - - /** - * Total local tax 1 amount - * @var float - */ - public $total_localtax1; - - /** - * Total local tax 2 amount - * @var float - */ - public $total_localtax2; - - /** - * Total amount with taxes - * @var float - */ - public $total_ttc; - - /** - * Liste d'options cumulables: - * Bit 0: 0 si TVA normal - 1 si TVA NPR - * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) - * @var int - */ - public $info_bits = 0; - - var $special_code; var $date_start; var $date_end; From 54b6b199c729bdf61211182e5e8962d12655b3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:03:40 +0100 Subject: [PATCH 15/21] Documented missing properties and removed redundant documentation (cherry picked from commit 6124f6a) --- htdocs/commande/class/commande.class.php | 25 ++++++-- htdocs/core/class/commonorder.class.php | 37 ++++++++++++ .../class/fournisseur.commande.class.php | 58 +++++++++++++------ 3 files changed, 96 insertions(+), 24 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index cdf73d58c7e..a79483bd979 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1604,12 +1604,12 @@ class Commande extends CommonOrder $line = new OrderLine($this->db); - $line->rowid = $objp->rowid; // \deprecated + $line->rowid = $objp->rowid; $line->id = $objp->rowid; $line->fk_commande = $objp->fk_commande; - $line->commande_id = $objp->fk_commande; // \deprecated + $line->commande_id = $objp->fk_commande; $line->label = $objp->custom_label; - $line->desc = $objp->description; // Description ligne + $line->desc = $objp->description; $line->product_type = $objp->product_type; $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; @@ -1635,11 +1635,11 @@ class Commande extends CommonOrder $line->special_code = $objp->special_code; $line->fk_parent_line = $objp->fk_parent_line; - $line->ref = $objp->product_ref; // TODO deprecated + $line->ref = $objp->product_ref; $line->product_ref = $objp->product_ref; - $line->libelle = $objp->product_label; // TODO deprecated + $line->libelle = $objp->product_label; $line->product_label = $objp->product_label; - $line->product_desc = $objp->product_desc; // Description produit + $line->product_desc = $objp->product_desc; $line->fk_product_type = $objp->fk_product_type; // Produit ou service $line->date_start = $this->db->jdate($objp->date_start); @@ -3236,6 +3236,19 @@ class OrderLine extends CommonOrderLine var $oldline; + /** + * Id of parent order + * @var int + */ + public $fk_commande; + + /** + * Id of parent order + * @var int + * @deprecated Use fk_commande + */ + public $commande_id; + // From llx_commandedet var $fk_parent_line; var $fk_facture; diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index eadf34d5583..b4882af8a58 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -39,12 +39,49 @@ abstract class CommonOrder extends CommonObject */ abstract class CommonOrderLine extends CommonObjectLine { + /** + * Product ref + * @var string + * @deprecated Use product_ref + */ + public $ref; + + /** + * Product ref + * @var string + */ + public $product_ref; + + /** + * Product label + * @var string + * @deprecated Use product_label + */ + public $libelle; + + /** + * Product label + * @var string + */ + public $product_label; + + /** + * Product description + * @var string + */ + public $product_desc; + /** * Quantity * @var int */ public $qty; + /** + * @deprecated + */ + var $price; + /** * Unit price before taxes * @var float diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index bc2e1e564b2..f3738fca2b4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -241,14 +241,14 @@ class CommandeFournisseur extends CommonOrder $line->id = $objp->rowid; $line->rowid = $objp->rowid; - $line->desc = $objp->description; // Description ligne - $line->description = $objp->description; // Description ligne + $line->desc = $objp->description; + $line->description = $objp->description; $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; - $line->subprice = $objp->subprice; // deprecated - $line->pu_ht = $objp->subprice; // Unit price HT + $line->subprice = $objp->subprice; + $line->pu_ht = $objp->subprice; $line->remise_percent = $objp->remise_percent; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -257,16 +257,16 @@ class CommandeFournisseur extends CommonOrder $line->total_ttc = $objp->total_ttc; $line->product_type = $objp->product_type; - $line->fk_product = $objp->fk_product; // Id du produit + $line->fk_product = $objp->fk_product; - $line->libelle = $objp->product_label; // TODO deprecated - $line->product_label = $objp->product_label; // Label produit - $line->product_desc = $objp->product_desc; // Description produit + $line->libelle = $objp->product_label; + $line->product_label = $objp->product_label; + $line->product_desc = $objp->product_desc; - $line->ref = $objp->product_ref; // TODO deprecated - $line->product_ref = $objp->product_ref; // Internal reference - $line->ref_fourn = $objp->ref_supplier; // TODO deprecated - $line->ref_supplier = $objp->ref_supplier; // Reference supplier + $line->ref = $objp->product_ref; + $line->product_ref = $objp->product_ref; + $line->ref_fourn = $objp->ref_supplier; + $line->ref_supplier = $objp->ref_supplier; $line->date_start = $this->db->jdate($objp->date_start); $line->date_end = $this->db->jdate($objp->date_end); @@ -2233,16 +2233,38 @@ class CommandeFournisseurLigne extends CommonOrderLine { public $element='commande_fournisseurdet'; public $table_element='commande_fournisseurdet'; + + /** + * Unit price without taxes + * @var float + */ + public $pu_ht; - var $date_start; + /** + * Unit price without taxes + * @var float + * @deprecated Use pu_ht + */ + public $subprice; + + + var $date_start; var $date_end; - // From llx_product - var $libelle; // Label produit - var $product_desc; // Description produit - // From llx_product_fournisseur_price - var $ref_fourn; // Ref supplier + + /** + * Supplier ref + * @var string + * @deprecated Use ref_supplier + */ + public $ref_fourn; + + /** + * Supplier reference + * @var string + */ + public $ref_supplier; /** From a7741350fe7940b2574adff02d5966569042a794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:41:40 +0100 Subject: [PATCH 16/21] Revert unwanted change --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 22f3c02a5a1..3ea6675cc8f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1841,7 +1841,7 @@ class FactureFournisseur extends CommonInvoice */ class SupplierInvoiceLine extends CommonInvoice { - public $element='fournisseur->facture'; + public $element='facture_fourn_det'; public $table_element='facture_fourn_det'; var $oldline; From 7a2e60bb65c97acaf487669ef85348bcf070373b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:45:30 +0100 Subject: [PATCH 17/21] No need to PHP < 5.3.0 compatibility --- htdocs/filefunc.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 7343e65c854..15bee891775 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -83,7 +83,6 @@ if (! empty($dolibarr_strict_mode)) } else { - if (! defined('E_DEPRECATED')) define('E_DEPRECATED',0); // For PHP < 5.3.0 compatibility error_reporting(E_ALL & ~(E_STRICT|E_NOTICE|E_DEPRECATED)); } From 6ec8a38e4a8221677dd08f21dc08323db6cbb689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 10:46:26 +0100 Subject: [PATCH 18/21] Removed duplicated code --- htdocs/commande/class/commande.class.php | 20 ------------------- .../class/fournisseur.commande.class.php | 8 -------- 2 files changed, 28 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a79483bd979..9c0d4c44aae 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3270,26 +3270,6 @@ class OrderLine extends CommonOrderLine */ var $remise; - /** - * @deprecated - */ - var $price; - - // From llx_product - /** - * @deprecated Use product_ref - */ - var $ref; - - /** - * @deprecated Use product_label - */ - var $libelle; - - var $product_ref; - var $product_label; // Label produit - var $product_desc; // Description produit - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Start and end date of the line var $date_start; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f3738fca2b4..41b9458e006 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2240,14 +2240,6 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public $pu_ht; - /** - * Unit price without taxes - * @var float - * @deprecated Use pu_ht - */ - public $subprice; - - var $date_start; var $date_end; From f94f9d1e577efe74de767441fd3af62465d7feb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 4 Mar 2015 11:19:45 +0100 Subject: [PATCH 19/21] Removed $permtoedit variable --- htdocs/core/class/commonobject.class.php | 7 +++---- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 523716a8c84..586d5af0171 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2571,7 +2571,7 @@ abstract class CommonObject * @param int $permtoedit Permission to edit line * @return void */ - function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $permtoedit=0) + function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0) { global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user; @@ -2659,7 +2659,7 @@ abstract class CommonObject } else { - $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline,$permtoedit); + $this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline); } $i++; @@ -2680,10 +2680,9 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param string $selected Object line selected * @param object $extrafieldsline Object of extrafield line attribute - * @param int $permtoedit Permission to edit * @return void */ - function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0,$permtoedit=0) + function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0) { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd, $object_rights; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 68724345411..689ac41d2ef 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1748,7 +1748,7 @@ elseif (! empty($object->id)) // Show object lines $inputalsopricewithtax=0; if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->commande->creer); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); $num = count($object->lines); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 01be69f1590..cd1e60a37ed 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2054,7 +2054,7 @@ else // Show object lines if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1, $user->rights->fournisseur->facture->creer); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); $num=count($object->lines); From bcdf3407c7c1d7bbb50090bc2bf3f2215c3d7ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 15 Mar 2015 18:01:21 +0100 Subject: [PATCH 20/21] Fixed line endings --- htdocs/includes/tcpdi/fpdf_tpl.php | 920 ++++++++++++++--------------- 1 file changed, 460 insertions(+), 460 deletions(-) diff --git a/htdocs/includes/tcpdi/fpdf_tpl.php b/htdocs/includes/tcpdi/fpdf_tpl.php index 86e38b71641..8482ba336ed 100644 --- a/htdocs/includes/tcpdi/fpdf_tpl.php +++ b/htdocs/includes/tcpdi/fpdf_tpl.php @@ -1,460 +1,460 @@ -Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); - return; - } - - if ($this->page <= 0) - $this->error("You have to add a page to fpdf first!"); - - if ($x == null) - $x = 0; - if ($y == null) - $y = 0; - if ($w == null) - $w = $this->w; - if ($h == null) - $h = $this->h; - - // Save settings - $this->tpl++; - $tpl =& $this->tpls[$this->tpl]; - $tpl = array( - 'o_x' => $this->x, - 'o_y' => $this->y, - 'o_AutoPageBreak' => $this->AutoPageBreak, - 'o_bMargin' => $this->bMargin, - 'o_tMargin' => $this->tMargin, - 'o_lMargin' => $this->lMargin, - 'o_rMargin' => $this->rMargin, - 'o_h' => $this->h, - 'o_w' => $this->w, - 'o_FontFamily' => $this->FontFamily, - 'o_FontStyle' => $this->FontStyle, - 'o_FontSizePt' => $this->FontSizePt, - 'o_FontSize' => $this->FontSize, - 'buffer' => '', - 'x' => $x, - 'y' => $y, - 'w' => $w, - 'h' => $h - ); - - $this->SetAutoPageBreak(false); - - // Define own high and width to calculate possitions correct - $this->h = $h; - $this->w = $w; - - $this->_intpl = true; - $this->SetXY($x + $this->lMargin, $y + $this->tMargin); - $this->SetRightMargin($this->w - $w + $this->rMargin); - - if ($this->CurrentFont) { - $fontkey = $this->FontFamily . $this->FontStyle; - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - - $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } - - return $this->tpl; - } - - /** - * End Template - * - * This method ends a template and reset initiated variables on beginTemplate. - * - * @return mixed If a template is opened, the ID is returned. If not a false is returned. - */ - function endTemplate() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); - } - - if ($this->_intpl) { - $this->_intpl = false; - $tpl =& $this->tpls[$this->tpl]; - $this->SetXY($tpl['o_x'], $tpl['o_y']); - $this->tMargin = $tpl['o_tMargin']; - $this->lMargin = $tpl['o_lMargin']; - $this->rMargin = $tpl['o_rMargin']; - $this->h = $tpl['o_h']; - $this->w = $tpl['o_w']; - $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); - - $this->FontFamily = $tpl['o_FontFamily']; - $this->FontStyle = $tpl['o_FontStyle']; - $this->FontSizePt = $tpl['o_FontSizePt']; - $this->FontSize = $tpl['o_FontSize']; - - $fontkey = $this->FontFamily . $this->FontStyle; - if ($fontkey) - $this->CurrentFont =& $this->fonts[$fontkey]; - - return $this->tpl; - } else { - return false; - } - } - - /** - * Use a Template in current Page or other Template - * - * You can use a template in a page or in another template. - * You can give the used template a new size like you use the Image()-method. - * All parameters are optional. The width or height is calculated automaticaly - * if one is given. If no parameter is given the origin size as defined in - * beginTemplate() is used. - * The calculated or used width and height are returned as an array. - * - * @param int $tplidx A valid template-Id - * @param int $_x The x-position - * @param int $_y The y-position - * @param int $_w The new width of the template - * @param int $_h The new height of the template - * @retrun array The height and width of the template - */ - function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { - if ($this->page <= 0) - $this->error('You have to add a page first!'); - - if (!isset($this->tpls[$tplidx])) - $this->error('Template does not exist!'); - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; - } - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_x == null) - $_x = 0; - if ($_y == null) - $_y = 0; - - $_x += $tpl['x']; - $_y += $tpl['y']; - - $wh = $this->getTemplateSize($tplidx, $_w, $_h); - $_w = $wh['w']; - $_h = $wh['h']; - - $tData = array( - 'x' => $this->x, - 'y' => $this->y, - 'w' => $_w, - 'h' => $_h, - 'scaleX' => ($_w / $w), - 'scaleY' => ($_h / $h), - 'tx' => $_x, - 'ty' => ($this->h - $_y - $_h), - 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) - ); - - $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); - - $this->lastUsedTemplateData = $tData; - - return array('w' => $_w, 'h' => $_h); - } - - /** - * Get The calculated Size of a Template - * - * If one size is given, this method calculates the other one. - * - * @param int $tplidx A valid template-Id - * @param int $_w The width of the template - * @param int $_h The height of the template - * @return array The height and width of the template - */ - function getTemplateSize($tplidx, $_w = 0, $_h = 0) { - if (!isset($this->tpls[$tplidx])) - return false; - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_w == 0 and $_h == 0) { - $_w = $w; - $_h = $h; - } - - if($_w == 0) - $_w = $_h * $w / $h; - if($_h == 0) - $_h = $_w * $h / $w; - - return array("w" => $_w, "h" => $_h); - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - public function SetFont($family, $style = '', $size = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); - } - - parent::SetFont($family, $style, $size); - - $fontkey = $this->FontFamily . $this->FontStyle; - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } else { - $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - function Image( - $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, - $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, - $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() - ) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Image'), $args); - } - - $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; - } else { - $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; - } - - return $ret; - } - - /** - * See FPDF-Documentation ;-) - * - * AddPage is not available when you're "in" a template. - */ - function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); - } - - if ($this->_intpl) - $this->Error('Adding pages in templates isn\'t possible!'); - - parent::AddPage($orientation, $format); - } - - /** - * Preserve adding Links in Templates ...won't work - */ - function Link($x, $y, $w, $h, $link, $spaces = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Link'), $args); - } - - if ($this->_intpl) - $this->Error('Using links in templates aren\'t possible!'); - - parent::Link($x, $y, $w, $h, $link); - } - - function AddLink() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); - } - - if ($this->_intpl) - $this->Error('Adding links in templates aren\'t possible!'); - return parent::AddLink(); - } - - function SetLink($link, $y = 0, $page = -1) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); - } - - if ($this->_intpl) - $this->Error('Setting links in templates aren\'t possible!'); - parent::SetLink($link, $y, $page); - } - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - // llx - $tpl['x'] * $this->k, - // lly - -$tpl['y'] * $this->k, - // urx - ($tpl['w'] + $tpl['x']) * $this->k, - // ury - ($tpl['h'] - $tpl['y']) * $this->k - )); - - if ($tpl['x'] != 0 || $tpl['y'] != 0) { - $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', - -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 - )); - } - - $this->_out('/Resources '); - - $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_putstream($p); - $this->_out('endobj'); - } - } - - /** - * Overwritten to add _putformxobjects() after _putimages() - * - */ - function _putimages() { - parent::_putimages(); - $this->_putformxobjects(); - } - - function _putxobjectdict() { - parent::_putxobjectdict(); - - if (count($this->tpls)) { - foreach($this->tpls as $tplidx => $tpl) { - $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); - } - } - } - - /** - * Private Method - */ - function _out($s) { - if ($this->state == 2 && $this->_intpl) { - $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; - } else { - parent::_out($s); - } - } -} +Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); + return; + } + + if ($this->page <= 0) + $this->error("You have to add a page to fpdf first!"); + + if ($x == null) + $x = 0; + if ($y == null) + $y = 0; + if ($w == null) + $w = $this->w; + if ($h == null) + $h = $this->h; + + // Save settings + $this->tpl++; + $tpl =& $this->tpls[$this->tpl]; + $tpl = array( + 'o_x' => $this->x, + 'o_y' => $this->y, + 'o_AutoPageBreak' => $this->AutoPageBreak, + 'o_bMargin' => $this->bMargin, + 'o_tMargin' => $this->tMargin, + 'o_lMargin' => $this->lMargin, + 'o_rMargin' => $this->rMargin, + 'o_h' => $this->h, + 'o_w' => $this->w, + 'o_FontFamily' => $this->FontFamily, + 'o_FontStyle' => $this->FontStyle, + 'o_FontSizePt' => $this->FontSizePt, + 'o_FontSize' => $this->FontSize, + 'buffer' => '', + 'x' => $x, + 'y' => $y, + 'w' => $w, + 'h' => $h + ); + + $this->SetAutoPageBreak(false); + + // Define own high and width to calculate possitions correct + $this->h = $h; + $this->w = $w; + + $this->_intpl = true; + $this->SetXY($x + $this->lMargin, $y + $this->tMargin); + $this->SetRightMargin($this->w - $w + $this->rMargin); + + if ($this->CurrentFont) { + $fontkey = $this->FontFamily . $this->FontStyle; + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + + $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); + } + + return $this->tpl; + } + + /** + * End Template + * + * This method ends a template and reset initiated variables on beginTemplate. + * + * @return mixed If a template is opened, the ID is returned. If not a false is returned. + */ + function endTemplate() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); + } + + if ($this->_intpl) { + $this->_intpl = false; + $tpl =& $this->tpls[$this->tpl]; + $this->SetXY($tpl['o_x'], $tpl['o_y']); + $this->tMargin = $tpl['o_tMargin']; + $this->lMargin = $tpl['o_lMargin']; + $this->rMargin = $tpl['o_rMargin']; + $this->h = $tpl['o_h']; + $this->w = $tpl['o_w']; + $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); + + $this->FontFamily = $tpl['o_FontFamily']; + $this->FontStyle = $tpl['o_FontStyle']; + $this->FontSizePt = $tpl['o_FontSizePt']; + $this->FontSize = $tpl['o_FontSize']; + + $fontkey = $this->FontFamily . $this->FontStyle; + if ($fontkey) + $this->CurrentFont =& $this->fonts[$fontkey]; + + return $this->tpl; + } else { + return false; + } + } + + /** + * Use a Template in current Page or other Template + * + * You can use a template in a page or in another template. + * You can give the used template a new size like you use the Image()-method. + * All parameters are optional. The width or height is calculated automaticaly + * if one is given. If no parameter is given the origin size as defined in + * beginTemplate() is used. + * The calculated or used width and height are returned as an array. + * + * @param int $tplidx A valid template-Id + * @param int $_x The x-position + * @param int $_y The y-position + * @param int $_w The new width of the template + * @param int $_h The new height of the template + * @retrun array The height and width of the template + */ + function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { + if ($this->page <= 0) + $this->error('You have to add a page first!'); + + if (!isset($this->tpls[$tplidx])) + $this->error('Template does not exist!'); + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; + } + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_x == null) + $_x = 0; + if ($_y == null) + $_y = 0; + + $_x += $tpl['x']; + $_y += $tpl['y']; + + $wh = $this->getTemplateSize($tplidx, $_w, $_h); + $_w = $wh['w']; + $_h = $wh['h']; + + $tData = array( + 'x' => $this->x, + 'y' => $this->y, + 'w' => $_w, + 'h' => $_h, + 'scaleX' => ($_w / $w), + 'scaleY' => ($_h / $h), + 'tx' => $_x, + 'ty' => ($this->h - $_y - $_h), + 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) + ); + + $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate + $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); + + $this->lastUsedTemplateData = $tData; + + return array('w' => $_w, 'h' => $_h); + } + + /** + * Get The calculated Size of a Template + * + * If one size is given, this method calculates the other one. + * + * @param int $tplidx A valid template-Id + * @param int $_w The width of the template + * @param int $_h The height of the template + * @return array The height and width of the template + */ + function getTemplateSize($tplidx, $_w = 0, $_h = 0) { + if (!isset($this->tpls[$tplidx])) + return false; + + $tpl =& $this->tpls[$tplidx]; + $w = $tpl['w']; + $h = $tpl['h']; + + if ($_w == 0 and $_h == 0) { + $_w = $w; + $_h = $h; + } + + if($_w == 0) + $_w = $_h * $w / $h; + if($_h == 0) + $_h = $_w * $h / $w; + + return array("w" => $_w, "h" => $_h); + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + public function SetFont($family, $style = '', $size = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); + } + + parent::SetFont($family, $style, $size); + + $fontkey = $this->FontFamily . $this->FontStyle; + + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } else { + $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; + } + } + + /** + * See FPDF/TCPDF-Documentation ;-) + */ + function Image( + $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, + $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, + $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() + ) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Image'), $args); + } + + $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); + if ($this->_intpl) { + $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; + } else { + $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; + } + + return $ret; + } + + /** + * See FPDF-Documentation ;-) + * + * AddPage is not available when you're "in" a template. + */ + function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); + } + + if ($this->_intpl) + $this->Error('Adding pages in templates isn\'t possible!'); + + parent::AddPage($orientation, $format); + } + + /** + * Preserve adding Links in Templates ...won't work + */ + function Link($x, $y, $w, $h, $link, $spaces = 0) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::Link'), $args); + } + + if ($this->_intpl) + $this->Error('Using links in templates aren\'t possible!'); + + parent::Link($x, $y, $w, $h, $link); + } + + function AddLink() { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); + } + + if ($this->_intpl) + $this->Error('Adding links in templates aren\'t possible!'); + return parent::AddLink(); + } + + function SetLink($link, $y = 0, $page = -1) { + if (is_subclass_of($this, 'TCPDF')) { + $args = func_get_args(); + return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); + } + + if ($this->_intpl) + $this->Error('Setting links in templates aren\'t possible!'); + parent::SetLink($link, $y, $page); + } + + /** + * Private Method that writes the form xobjects + */ + function _putformxobjects() { + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->tpls); + foreach($this->tpls AS $tplidx => $tpl) { + + $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; + $this->_newobj(); + $this->tpls[$tplidx]['n'] = $this->n; + $this->_out('<<'.$filter.'/Type /XObject'); + $this->_out('/Subtype /Form'); + $this->_out('/FormType 1'); + $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', + // llx + $tpl['x'] * $this->k, + // lly + -$tpl['y'] * $this->k, + // urx + ($tpl['w'] + $tpl['x']) * $this->k, + // ury + ($tpl['h'] - $tpl['y']) * $this->k + )); + + if ($tpl['x'] != 0 || $tpl['y'] != 0) { + $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', + -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 + )); + } + + $this->_out('/Resources '); + + $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { + $this->_out('/Font <<'); + foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) + $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); + $this->_out('>>'); + } + if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || + isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) + { + $this->_out('/XObject <<'); + if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { + foreach($this->_res['tpl'][$tplidx]['images'] as $image) + $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); + } + if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { + foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) + $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); + } + $this->_out('>>'); + } + $this->_out('>>'); + + $this->_out('/Length ' . strlen($p) . ' >>'); + $this->_putstream($p); + $this->_out('endobj'); + } + } + + /** + * Overwritten to add _putformxobjects() after _putimages() + * + */ + function _putimages() { + parent::_putimages(); + $this->_putformxobjects(); + } + + function _putxobjectdict() { + parent::_putxobjectdict(); + + if (count($this->tpls)) { + foreach($this->tpls as $tplidx => $tpl) { + $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); + } + } + } + + /** + * Private Method + */ + function _out($s) { + if ($this->state == 2 && $this->_intpl) { + $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; + } else { + parent::_out($s); + } + } +} From 6ba3b900b7aed1b8298c4f287b73c694d2a876f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 15 Mar 2015 23:42:11 +0100 Subject: [PATCH 21/21] PHPCS Fix --- htdocs/core/class/commonobject.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0a682415b94..e781405344b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2662,7 +2662,6 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param string $selected Object line selected * @param int $dateSelector 1=Show also date range input fields - * @param int $permtoedit Permission to edit line * @return void */ function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)