diff --git a/ChangeLog b/ChangeLog
index 361cd1145ba..803703caf9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,10 +62,12 @@ For users:
- New: Can choose menu entry to show with external site module.
- New: Add hidden option MAIN_PDF_MARGIN_LEFT, MAIN_PDF_MARGIN_RIGHT, MAIN_PDF_MARGIN_TOP, MAIN_PDF_MARGIN_BOTTOM
to force margins of generated PDF.
+- New: [ task #314 ] Can define if prof id are mandatory or not
New experimental modules:
- New: Add margin management module.
- New: Add commissions management module.
+
- Fix: [ bug #499 ]: Supplier order input method not translated
- Fix: No images into product description lines as PDF generation does
not work with this.
diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php
index 9200524f259..6107560d656 100644
--- a/dev/skeletons/modMyModule.class.php
+++ b/dev/skeletons/modMyModule.class.php
@@ -111,9 +111,9 @@ class modMyModule extends DolibarrModules
$this->const = array();
// Array to add new pages in new tabs
- // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1
- // 'objecttype:+tabname2:Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2
- // 'objecttype:-tabname':NU:conditiontoremove); // To remove an existing tab identified by code tabname
+ // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1
+ // 'objecttype:+tabname2:Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2
+ // 'objecttype:-tabname'); // To remove an existing tab identified by code tabname
// where objecttype can be
// 'thirdparty' to add a tab in third party view
// 'intervention' to add a tab in intervention view
diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php
index dcc25501d84..302992a707b 100755
--- a/htdocs/adherents/stats/byproperties.php
+++ b/htdocs/adherents/stats/byproperties.php
@@ -22,8 +22,8 @@
*/
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$graphwidth = 700;
$mapratio = 0.5;
@@ -83,8 +83,8 @@ if ($resql)
{
$obj=$db->fetch_object($resql);
- if ($obj->code == 'phy') $foundphy++;
- if ($obj->code == 'mor') $foundmor++;
+ if ($obj->code == 'phy') $foundphy++;
+ if ($obj->code == 'mor') $foundmor++;
$data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate));
@@ -122,8 +122,8 @@ print '
'.$langs->trans("NbOfMembers").' ';
print ''.$langs->trans("LastMemberDate").' ';
print '';
-if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');
-if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'');
+if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');
+if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'');
$oldyear=0;
$var=true;
diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php
index 5af5b8a5787..c0d9d389627 100644
--- a/htdocs/admin/agenda.php
+++ b/htdocs/admin/agenda.php
@@ -94,34 +94,6 @@ if ($action == "save" && empty($cancel))
}
}
-if (preg_match('/set_(.*)/',$action,$reg))
-{
- $code=$reg[1];
- $value=(GETPOST($code) ? GETPOST($code) : 1);
- if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
- {
- Header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- dol_print_error($db);
- }
-}
-
-if (preg_match('/del_(.*)/',$action,$reg))
-{
- $code=$reg[1];
- if (dolibarr_del_const($db, $code, $conf->entity) > 0)
- {
- Header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- dol_print_error($db);
- }
-}
/**
@@ -187,46 +159,6 @@ print "\n";
print '';
-/*
- * Other options
-*/
-
-print_titre($langs->trans("OtherOptions"));
-
-$var=true;
-
-print ''."\n";
-print ''."\n";
-print ''.$langs->trans("Parameters").' '."\n";
-print ' '."\n";
-print ''.$langs->trans("Value").' '."\n";
-print ' '."\n";
-
-// Manual or automatic
-$var=!$var;
-print ''."\n";
-print ''.$langs->trans("AGENDA_USE_EVENT_TYPE").' '."\n";
-print ' '."\n";
-
-print ''."\n";
-if ($conf->use_javascript_ajax)
-{
- print ajax_constantonoff('AGENDA_USE_EVENT_TYPE');
-}
-else
-{
- if($conf->global->AGENDA_USE_EVENT_TYPE == 0)
- {
- print ''.img_picto($langs->trans("Disabled"),'off').' ';
- }
- else if($conf->global->BUSINESS_VISIBLE_TO_ALL_BY_DEFAULT == 1)
- {
- print ''.img_picto($langs->trans("Enabled"),'on').' ';
- }
-}
-print ' '."\n";
-
-
print " ";
dol_htmloutput_mesg($mesg);
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 0bee6992ec1..30158915f2e 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -563,8 +563,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '';
print "";
print "".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code);
- print ($example!="LocalTax1IsUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
@@ -573,8 +572,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '';
print "";
print "".$langs->transcountry("LocalTax1IsNotUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code);
- print ($example!="LocalTax1IsNotUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
print "
";
@@ -595,8 +593,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '';
print "";
print "".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code);
- print ($example!="LocalTax2IsUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
@@ -605,8 +602,7 @@ if ($action == 'edit' || $action == 'updateedit')
print '';
print "";
print "".$langs->transcountry("LocalTax2IsNotUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code);
- print ($example!="LocalTax2IsNotUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
print "";
@@ -943,8 +939,7 @@ else
print '';
print "";
print "".$langs->transcountry("LocalTax1IsUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code);
- print ($example!="LocalTax1IsUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example",$mysoc->country_code).': '.$langs->transcountry("LocalTax1IsUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
@@ -953,8 +948,7 @@ else
print '';
print "";
print "".$langs->transcountry("LocalTax1IsNotUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code);
- print ($example!="LocalTax1IsNotUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example",$mysoc->country_code).': '.$langs->transcountry("LocalTax1IsNotUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
@@ -976,8 +970,7 @@ else
print '';
print "";
print "".$langs->transcountry("LocalTax2IsUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code);
- print ($example!="LocalTax2IsUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
@@ -986,8 +979,7 @@ else
print '';
print "";
print "".$langs->transcountry("LocalTax2IsNotUsedDesc",$mysoc->country_code)." ";
- $example=$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code);
- print ($example!="LocalTax2IsNotUsedExample"?"".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)." \n":"");
+ print "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$mysoc->country_code)." \n";
print "
";
print " \n";
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index e18420285c0..92111cd9a2c 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -1066,6 +1066,7 @@ if ($id)
}
}
+ print '';
// Est-ce une entree du dictionnaire qui peut etre desactivee ?
$iserasable=1; // Oui par defaut
if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable=0;
@@ -1073,14 +1074,8 @@ if ($id)
if (isset($obj->code) && $obj->code == 'EF0') $iserasable=0;
if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto'))) $iserasable=0;
- // Active
- print ' ';
if ($iserasable) print 'rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?$obj->code:'').'&id='.$id.'&action='.$acts[$obj->active].'">'.$actl[$obj->active].' ';
- else
- {
- if (isset($obj->type) && in_array($obj->type, array('system', 'systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
- else print $langs->trans("AlwaysActive");
- }
+ else print $langs->trans("AlwaysActive");
print " ";
// Modify link
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index a79650fa893..760651a7f2b 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -477,14 +477,12 @@ class ActionComm extends CommonObject
* @param int $fk_element Id of element action is linked to
* @param string $elementtype Type of element action is linked to
* @param string $filter Other filter
- * @return array <0 if KO, array with actions
+ * @return int <0 if KO, >0 if OK
*/
- static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='')
+ function getActions($socid=0, $fk_element=0, $elementtype='', $filter='')
{
global $conf, $langs;
- $resarray=array();
-
$sql = "SELECT a.id";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " WHERE a.entity = ".$conf->entity;
@@ -497,27 +495,27 @@ class ActionComm extends CommonObject
if (! empty($filter)) $sql.= $filter;
dol_syslog(get_class($this)."::getActions sql=".$sql);
- $resql=$db->query($sql);
+ $resql=$this->db->query($sql);
if ($resql)
{
- $num = $db->num_rows($resql);
+ $num = $this->db->num_rows($resql);
if ($num)
{
for($i=0;$i<$num;$i++)
{
- $obj = $db->fetch_object($resql);
- $actioncommstatic = new ActionComm($db);
+ $obj = $this->db->fetch_object($resql);
+ $actioncommstatic = new ActionComm($this->db);
$actioncommstatic->fetch($obj->id);
- $resarray[$i] = $actioncommstatic;
+ $this->actions[$i] = $actioncommstatic;
}
}
- $db->free($resql);
- return $resarray;
+ $this->db->free($resql);
+ return 1;
}
else
{
- $this->error=$db->lasterror();
+ $this->error=$this->db->lasterror();
return -1;
}
}
@@ -709,34 +707,26 @@ class ActionComm extends CommonObject
if ($option=='birthday') $lien = 'id.'">';
else $lien = ' id.'">';
$lienfin=' ';
- $label=$this->label;
- if (empty($label)) $label=$this->libelle; // Fro backward compatibility
- //print 'rrr'.$this->libelle;
-
+ //print $this->libelle;
if ($withpicto == 2)
{
- $libelle=$label;
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code);
+ $libelle=$langs->trans("Action".$this->type_code);
$libelleshort='';
}
else if (empty($this->libelle))
{
- $libelle=$label;
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) $libelle=$langs->trans("Action".$this->type_code);
- $libelleshort=dol_trunc($label, $maxlength);
+ $libelle=$langs->trans("Action".$this->type_code);
+ $libelleshort=$langs->trans("Action".$this->type_code,'','','','',$maxlength);
}
else
- {
- $libelle=$label;
- $libelleshort=dol_trunc($label,$maxlength);
+ {
+ $libelle=$this->libelle;
+ $libelleshort=dol_trunc($this->libelle,$maxlength);
}
if ($withpicto)
{
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
- {
- $libelle.=(($this->type_code && $libelle!=$langs->trans("Action".$this->type_code) && $langs->trans("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->trans("Action".$this->type_code).')':'');
- }
+ $libelle.=(($this->type_code && $libelle!=$langs->trans("Action".$this->type_code) && $langs->trans("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->trans("Action".$this->type_code).')':'');
$result.=$lien.img_object($langs->trans("ShowAction").': '.$libelle,($overwritepicto?$overwritepicto:'action')).$lienfin;
}
if ($withpicto==1) $result.=' ';
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index f1c8a4abbaf..50f9f077785 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -100,10 +100,9 @@ class CActionComm
* @param int $active 1 or 0 to filter on event state active or not ('' by default = no filter)
* @param string $idorcode 'id' or 'code'
* @param string $excludetype Type to exclude
- * @param string $onlyautoornot Group list by auto events or not
* @return array Array of all event types if OK, <0 if KO
*/
- function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0)
+ function liste_array($active='',$idorcode='id',$excludetype='')
{
global $langs,$conf;
$langs->load("commercial");
@@ -111,7 +110,7 @@ class CActionComm
$repid = array();
$repcode = array();
- $sql = "SELECT id, code, libelle, module, type";
+ $sql = "SELECT id, code, libelle, module";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm";
if ($active != '') $sql.=" WHERE active=".$active;
if (! empty($excludetype)) $sql.=($active != ''?" AND":" WHERE")." type <> '".$excludetype."'";
@@ -128,31 +127,20 @@ class CActionComm
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
-
$qualified=1;
-
- // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto
- if ($qualified && $onlyautoornot && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTHER)
-
- if ($qualified && $obj->module)
+ if ($obj->module)
{
if ($obj->module == 'invoice' && ! $conf->facture->enabled) $qualified=0;
if ($obj->module == 'order' && ! $conf->commande->enabled) $qualified=0;
if ($obj->module == 'propal' && ! $conf->propal->enabled) $qualified=0;
if ($obj->module == 'invoice_supplier' && ! $conf->fournisseur->enabled) $qualified=0;
if ($obj->module == 'order_supplier' && ! $conf->fournisseur->enabled) $qualified=0;
- if ($obj->module == 'shipping' && ! $conf->expedition->enabled) $qualified=0;
}
-
if ($qualified)
{
- $code=$obj->code;
- if ($onlyautoornot && $code == 'AC_OTH') $code='AC_MANUAL';
- if ($onlyautoornot && $code == 'AC_OTH_AUTO') $code='AC_AUTO';
- $transcode=$langs->trans("Action".$code);
- $repid[$obj->id] = ($transcode!="Action".$code?$transcode:$langs->trans($obj->libelle));
- $repcode[$obj->code] = ($transcode!="Action".$code?$transcode:$langs->trans($obj->libelle));
- if ($onlyautoornot && preg_match('/^module/',$obj->type) && $obj->module) $repcode[$obj->code].=' ('.$langs->trans("Module").': '.$obj->module.')';
+ $transcode=$langs->trans("Action".$obj->code);
+ $repid[$obj->id] = ($transcode!="Action".$obj->code?$transcode:$langs->trans($obj->libelle));
+ $repcode[$obj->code] = ($transcode!="Action".$obj->code?$transcode:$langs->trans($obj->libelle));
}
$i++;
}
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index db2e459f551..7fa1a71c5f3 100755
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -127,10 +127,7 @@ if ($objectid > 0)
print '';
// Type
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
- {
- print ''.$langs->trans("Type").' '.$act->type.' ';
- }
+ print ''.$langs->trans("Type").' '.$act->type.' ';
// Title
print ''.$langs->trans("Title").' '.$act->label.' ';
diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index 5b5ebee90ee..53b0dae69ab 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -107,13 +107,6 @@ if ($action == 'add_action')
$mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("DateEnd")).'
';
}
- if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && ! GETPOST('label'))
- {
- $error++;
- $action = 'create';
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("Title")).'
';
- }
-
// Initialisation objet cactioncomm
if (! GETPOST('actioncode'))
{
@@ -129,13 +122,13 @@ if ($action == 'add_action')
// Initialisation objet actioncomm
$actioncomm->type_id = $cactioncomm->id;
$actioncomm->type_code = $cactioncomm->code;
- $actioncomm->priority = GETPOST("priority")?GETPOST("priority"):0;
+ $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0;
$actioncomm->fulldayevent = (! empty($fulldayevent)?1:0);
- $actioncomm->location = GETPOST("location");
- $actioncomm->label = trim(GETPOST('label'));
- if (! GETPOST('label'))
+ $actioncomm->location = isset($_POST["location"])?$_POST["location"]:'';
+ $actioncomm->label = trim($_POST["label"]);
+ if (! $_POST["label"])
{
- if (GETPOST('actioncode') == 'AC_RDV' && $contact->getFullName($langs))
+ if ($_POST["actioncode"] == 'AC_RDV' && $contact->getFullName($langs))
{
$actioncomm->label = $langs->transnoentitiesnoconv("TaskRDVWith",$contact->getFullName($langs));
}
@@ -397,13 +390,11 @@ if ($action == 'create')
$(".fulldaystartmin").removeAttr("disabled");
$(".fulldayendhour").removeAttr("disabled");
$(".fulldayendmin").removeAttr("disabled");
- $("#p2").removeAttr("disabled");
} else {
$(".fulldaystarthour").attr("disabled","disabled").val("00");
$(".fulldaystartmin").attr("disabled","disabled").val("00");
$(".fulldayendhour").attr("disabled","disabled").val("23");
$(".fulldayendmin").attr("disabled","disabled").val("59");
- $("#p2").attr("disabled","disabled").val("");
}
}
setdatefields();
@@ -441,25 +432,21 @@ if ($action == 'create')
print '';
// Type d'action actifs
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
+ print ''.$langs->trans("Type").' ';
+ if (GETPOST("actioncode"))
{
- print ' '.$langs->trans("Type").' ';
- if (GETPOST("actioncode"))
- {
- print ' '."\n";
- $cactioncomm->fetch(GETPOST("actioncode"));
- print $cactioncomm->getNomUrl();
- }
- else
- {
- $htmlactions->select_type_actions($actioncomm->type_code, "actioncode","systemauto");
- }
- print ' ';
+ print ' '."\n";
+ $cactioncomm->fetch(GETPOST("actioncode"));
+ print $cactioncomm->getNomUrl();
}
- else print ' ';
+ else
+ {
+ $htmlactions->select_type_actions($actioncomm->type_code, "actioncode","systemauto");
+ }
+ print '';
// Title
- print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").' ';
+ print ''.$langs->trans("Title").' ';
// Full day
print ''.$langs->trans("EventOnFullDay").' ';
@@ -691,13 +678,10 @@ if ($id)
print ''.$langs->trans("Ref").' '.$act->id.' ';
// Type
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
- {
- print ''.$langs->trans("Type").' '.$act->type.' ';
- }
+ print ''.$langs->trans("Type").' '.$act->type.' ';
// Title
- print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").' ';
+ print ''.$langs->trans("Title").' ';
// Full day event
print ''.$langs->trans("EventOnFullDay").' fulldayevent?' checked="checked"':'').'> ';
@@ -813,10 +797,7 @@ if ($id)
print '';
// Type
- if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
- {
- print ''.$langs->trans("Type").' '.$act->type.' ';
- }
+ print ''.$langs->trans("Type").' '.$act->type.' ';
// Title
print ''.$langs->trans("Title").' '.$act->label.' ';
diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php
index a3f7c8ef647..7d03960dd11 100644
--- a/htdocs/comm/addpropal.php
+++ b/htdocs/comm/addpropal.php
@@ -340,7 +340,6 @@ if ($action == 'create')
$langs->load("bills");
print '';
print ' ';
- print ' ';
print ' ';
print "";
diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php
index ef99fd6ee3a..89fba20a60c 100644
--- a/htdocs/commissions/lib/commissions.lib.php
+++ b/htdocs/commissions/lib/commissions.lib.php
@@ -41,10 +41,8 @@ function commissions_admin_prepare_head()
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
- complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin');
-
- complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin','remove');
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
+ complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin');
return $head;
}
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 25153612f56..0f12ab0cfc8 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -546,12 +546,17 @@ class BonPrelevement extends CommonObject
// TODO Call trigger to create a notification using notification module
}
else
- {
+ {
dol_syslog(get_class($this)."::set_infotrans Erreur 1", LOG_ERR);
dol_syslog($this->db->error());
$error++;
}
+ /*
+ * End of procedure
+ *
+ */
+
if ($error == 0)
{
$this->db->commit();
@@ -1042,44 +1047,6 @@ class BonPrelevement extends CommonObject
}
- /**
- * Get object and lines from database
- *
- * @return int >0 if OK, <0 if KO
- */
- function delete()
- {
- $this->db->begin();
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_facture WHERE fk_prelevement_lignes IN (SELECT rowid FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = '".$this->id."')";
- $resql1=$this->db->query($sql);
- if (! $resql1) dol_print_error($this->db);
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_lignes WHERE fk_prelevement_bons = '".$this->id."'";
- $resql2=$this->db->query($sql);
- if (! $resql2) dol_print_error($this->db);
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."prelevement_bons WHERE rowid = '".$this->id."'";
- $resql3=$this->db->query($sql);
- if (! $resql3) dol_print_error($this->db);
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_facture_demande SET fk_prelevement_bons = NULL, traite = 0 WHERE fk_prelevement_bons = '".$this->id."'";
- $resql4=$this->db->query($sql);
- if (! $resql4) dol_print_error($this->db);
-
- if ($resql1 && $resql2 && $resql3)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
-
-
/**
* Returns clickable name (with picto)
*
@@ -1628,20 +1595,20 @@ class BonPrelevement extends CommonObject
{
if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut0').' '.$langs->trans($this->labelstatut[$statut]);
if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]);
- if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]);
+ if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut4').' '.$langs->trans($this->labelstatut[$statut]);
}
if ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1');
- if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6');
+ if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut4');
}
if ($mode == 3)
{
if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut0');
if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1');
- if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6');
+ if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut4');
}
}
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index e30e3f05d82..aed9237e028 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -55,21 +55,27 @@ if ($prev_id)
dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalReceipt"), '', 'payment');
print '';
-
- print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
+ print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($bon->datec,'day').' ';
print ''.$langs->trans("Amount").' '.price($bon->amount).' ';
-
+ print ''.$langs->trans("File").' ';
+
+ $relativepath = 'receipts/'.$bon->ref;
+
+ print ''.$relativepath.' ';
+
+ print ' ';
+
// Status
print ''.$langs->trans('Status').' ';
print ''.$bon->getLibStatut(1).' ';
print ' ';
-
+
if($bon->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($bon->user_trans);
-
+
print ''.$langs->trans("TransData").' ';
print dol_print_date($bon->date_trans,'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).' ';
@@ -83,19 +89,10 @@ if ($prev_id)
print dol_print_date($bon->date_credit,'day');
print '';
}
-
- print '
';
-
- print ' ';
-
- print '';
- print $langs->trans("WithdrawalFile").' ';
- $relativepath = 'receipts/'.$bon->ref;
- print ''.$relativepath.' ';
- print '
';
-
- dol_fiche_end();
-
+
+ print '
';
+
+ print '';
}
else
{
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index 5ff3d5544d9..2ca9479f441 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -54,21 +54,27 @@ if ($prev_id)
dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalReceipt"), '', 'payment');
print '';
-
- print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
+ print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($bon->datec,'day').' ';
print ''.$langs->trans("Amount").' '.price($bon->amount).' ';
-
+ print ''.$langs->trans("File").' ';
+
+ $relativepath = 'receipts/'.$bon->ref;
+
+ print ''.$relativepath.' ';
+
+ print ' ';
+
// Status
print ''.$langs->trans('Status').' ';
print ''.$bon->getLibStatut(1).' ';
print ' ';
-
+
if($bon->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($bon->user_trans);
-
+
print ''.$langs->trans("TransData").' ';
print dol_print_date($bon->date_trans,'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).' ';
@@ -82,19 +88,10 @@ if ($prev_id)
print dol_print_date($bon->date_credit,'day');
print '';
}
-
- print '
';
-
- print ' ';
-
- print '';
- print $langs->trans("WithdrawalFile").' ';
- $relativepath = 'receipts/'.$bon->ref;
- print ''.$relativepath.' ';
- print '
';
-
- dol_fiche_end();
-
+
+ print '';
+
+ print '';
}
else
{
@@ -106,6 +103,8 @@ $rej = new RejetPrelevement($db, $user);
/*
* Liste des factures
+ *
+ *
*/
$sql = "SELECT pl.rowid, pl.amount, pl.statut";
$sql.= " , s.rowid as socid, s.nom";
@@ -142,10 +141,10 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
- print "";
-
+ print " ";
+ print ' ';
print '';
- print img_picto('', 'statut'.$obj->statut).' ';
+
print substr('000000'.$obj->rowid, -6);
print ' ';
print ''.stripslashes($obj->nom)." \n";
@@ -165,7 +164,7 @@ if ($resql)
print ' ';
print ''.$langs->trans("Total").' ';
print ''.price($total)." \n";
- print ' ';
+ print ' ';
print " \n\n";
$db->free($resql);
}
diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php
index eab046c7d45..5497b1acf2a 100644
--- a/htdocs/compta/prelevement/fiche-stat.php
+++ b/htdocs/compta/prelevement/fiche-stat.php
@@ -58,17 +58,24 @@ if ($prev_id)
print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($bon->datec,'day').' ';
print ''.$langs->trans("Amount").' '.price($bon->amount).' ';
-
+ print ''.$langs->trans("File").' ';
+
+ $relativepath = 'receipts/'.$bon->ref;
+
+ print ''.$relativepath.' ';
+
+ print ' ';
+
// Status
print ''.$langs->trans('Status').' ';
print ''.$bon->getLibStatut(1).' ';
print ' ';
-
+
if($bon->date_trans <> 0)
{
$muser = new User($db);
$muser->fetch($bon->user_trans);
-
+
print ''.$langs->trans("TransData").' ';
print dol_print_date($bon->date_trans,'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).' ';
@@ -82,19 +89,10 @@ if ($prev_id)
print dol_print_date($bon->date_credit,'day');
print '';
}
-
+
print '';
-
- print ' ';
-
- print '';
- print $langs->trans("WithdrawalFile").' ';
- $relativepath = 'receipts/'.$bon->ref;
- print ''.$relativepath.' ';
- print '
';
-
- dol_fiche_end();
-
+
+ print '';
}
else
{
diff --git a/htdocs/compta/prelevement/fiche.php b/htdocs/compta/prelevement/fiche.php
index 73450228480..cd99849de9c 100644
--- a/htdocs/compta/prelevement/fiche.php
+++ b/htdocs/compta/prelevement/fiche.php
@@ -42,28 +42,14 @@ if ($user->societe_id > 0) accessforbidden();
$action = GETPOST('action','alpha');
$id = GETPOST('id','int');
-
/*
* Actions
*/
-if ( $action == 'confirm_delete' )
-{
- $bon = new BonPrelevement($db,"");
- $bon->fetch($id);
-
- $res=$bon->delete();
- if ($res > 0)
- {
- header("Location: index.php");
- exit;
- }
-}
if ( $action == 'confirm_credite' && GETPOST('confirm','alpha') == 'yes')
{
$bon = new BonPrelevement($db,"");
- $bon->fetch($id);
-
+ $bon->id = $id;
$bon->set_credite();
header("Location: fiche.php?id=".$id);
@@ -77,15 +63,14 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
$bon = new BonPrelevement($db,"");
$bon->fetch($id);
- $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
-
- /*
if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $bon->ref)
{
$dir = $conf->prelevement->dir_output.'/receipts';
if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
{
+ $dt = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
+
$bon->set_infotrans($user, $dt, GETPOST('methode','alpha'));
}
@@ -96,14 +81,6 @@ if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
{
dol_syslog("Fichier invalide",LOG_WARNING);
$mesg='BadFile';
- }*/
-
- $error = $bon->set_infotrans($user, $dt, GETPOST('methode','alpha'));
-
- if ($error)
- {
- header("Location: fiche.php?id=".$id."&error=$error");
- exit;
}
}
@@ -115,11 +92,15 @@ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
$error = $bon->set_infocredit($user, $dt);
- if ($error)
+ if ($error == 0)
+ {
+ header("Location: fiche.php?id=".$id);
+ }
+ else
{
header("Location: fiche.php?id=".$id."&error=$error");
- exit;
}
+ exit;
}
@@ -127,139 +108,132 @@ if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
* View
*/
-$bon = new BonPrelevement($db,"");
-$form = new Form($db);
-
llxHeader('',$langs->trans("WithdrawalReceipt"));
+$form = new Form($db);
-if ($id > 0)
+if ($id)
{
- $bon->fetch($id);
+ $bon = new BonPrelevement($db,"");
- $head = prelevement_prepare_head($bon);
- dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalReceipt"), '', 'payment');
-
- if (GETPOST('error','alpha')!='')
+ if ($bon->fetch($id) == 0)
{
- print ''.$bon->ReadError(GETPOST('error','alpha')).'
';
- }
+ $head = prelevement_prepare_head($bon);
+ dol_fiche_head($head, 'prelevement', $langs->trans("WithdrawalReceipt"), '', 'payment');
- /*if ($action == 'credite')
- {
- $ret=$form->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1);
- if ($ret == 'html') print ' ';
- }*/
+ if (GETPOST('error','alpha')!='')
+ {
+ print ''.$bon->ReadError(GETPOST('error','alpha')).'
';
+ }
- print '';
+ if ($action == 'credite')
+ {
+ $ret=$form->form_confirm("fiche.php?id=".$bon->id,$langs->trans("ClassCredited"),$langs->trans("ClassCreditedConfirm"),"confirm_credite",'',1,1);
+ if ($ret == 'html') print ' ';
+ }
- print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
- print ''.$langs->trans("Date").' '.dol_print_date($bon->datec,'day').' ';
- print ''.$langs->trans("Amount").' '.price($bon->amount).' ';
-
- // Status
- print ''.$langs->trans('Status').' ';
- print ''.$bon->getLibStatut(1).' ';
- print ' ';
-
- if($bon->date_trans <> 0)
- {
- $muser = new User($db);
- $muser->fetch($bon->user_trans);
-
- print ''.$langs->trans("TransData").' ';
- print dol_print_date($bon->date_trans,'day');
- print ' '.$langs->trans("By").' '.$muser->getFullName($langs).' ';
- print ''.$langs->trans("TransMetod").' ';
- print $bon->methodes_trans[$bon->method_trans];
- print ' ';
- }
- if($bon->date_credit <> 0)
- {
- print ''.$langs->trans('CreditDate').' ';
- print dol_print_date($bon->date_credit,'day');
- print ' ';
- }
-
- print '
';
-
- print ' ';
-
- print '';
- print $langs->trans("WithdrawalFile").' ';
- $relativepath = 'receipts/'.$bon->ref;
- print ''.$relativepath.' ';
- print '
';
-
- dol_fiche_end();
-
-
-
-
- if (empty($bon->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted')
- {
- print '';
- }
- if (! empty($bon->date_trans) && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit && $action=='setcredited')
- {
- print '';
+ dol_fiche_end();
+
+ if($bon->date_trans == 0 && $user->rights->prelevement->bons->send)
+ {
+ print '';
+ }
+
+ if($bon->date_trans <> 0 && $bon->date_credit == 0 && $user->rights->prelevement->bons->credit)
+ {
+ print '';
+ }
}
-
-
- // Actions
- if ($action != 'settransmitted' && $action != 'setcredited')
+ else
{
- print "\n";
+ dol_print_error($db);
}
}
+/* ************************************************************************** */
+/* */
+/* Barre d'action */
+/* */
+/* ************************************************************************** */
-llxFooter();
+/*
+print "\n\n";
$db->close();
+
+llxFooter();
?>
diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php
index 2f2dd82fcb7..8dba0b37cae 100644
--- a/htdocs/compta/prelevement/index.php
+++ b/htdocs/compta/prelevement/index.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2012 Laurent Destailleur
+ * Copyright (C) 2005-2011 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
*
@@ -93,10 +93,10 @@ print '';
* Withdraw receipts
*/
$limit=5;
-$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
-$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
-$sql.= " ORDER BY datec DESC";
-$sql.= $db->plimit($limit);
+$sql = "SELECT p.rowid, p.ref, p.amount, p.datec";
+$sql .= " ,p.statut ";
+$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
+$sql .= " ORDER BY datec DESC LIMIT ".$limit;
$result = $db->query($sql);
if ($result)
@@ -110,7 +110,6 @@ if ($result)
print ' '.$langs->trans("LastWithdrawalReceipt",$limit).' ';
print ''.$langs->trans("Date").' ';
print ''.$langs->trans("Amount").' ';
- print ''.$langs->trans("Status").' ';
print ' ';
while ($i < min($num,$limit))
@@ -118,17 +117,15 @@ if ($result)
$obj = $db->fetch_object($result);
$var=!$var;
- print "";
+ print " ";
+
+ print ' ';
+
+ print ''.$obj->ref." \n";
- print "";
- $bprev->id=$obj->rowid;
- $bprev->ref=$obj->ref;
- $bprev->statut=$obj->statut;
- print $bprev->getNomUrl(1);
- print " \n";
print ''.dol_print_date($db->jdate($obj->datec),"dayhour")." \n";
+
print ''.price($obj->amount)." \n";
- print ''.$bprev->getLibStatut(3)." \n";
print " \n";
$i++;
diff --git a/htdocs/compta/prelevement/lignes.php b/htdocs/compta/prelevement/lignes.php
index 6276e745d72..4e9636af6a4 100644
--- a/htdocs/compta/prelevement/lignes.php
+++ b/htdocs/compta/prelevement/lignes.php
@@ -65,6 +65,13 @@ if ($prev_id)
print ''.$langs->trans("Ref").' '.$bon->getNomUrl(1).' ';
print ''.$langs->trans("Date").' '.dol_print_date($bon->datec,'day').' ';
print ''.$langs->trans("Amount").' '.price($bon->amount).' ';
+ print ''.$langs->trans("File").' ';
+
+ $relativepath = 'receipts/'.$bon->ref;
+
+ print ''.$relativepath.' ';
+
+ print ' ';
// Status
print ''.$langs->trans('Status').' ';
@@ -92,16 +99,7 @@ if ($prev_id)
print '';
- print ' ';
-
- print '';
- print $langs->trans("WithdrawalFile").' ';
- $relativepath = 'receipts/'.$bon->ref;
- print ''.$relativepath.' ';
- print '
';
-
- dol_fiche_end();
-
+ print '';
}
else
{
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 4e2d80e7bd1..fd8a2c82101 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -127,6 +127,7 @@ class Contact extends CommonObject
$sql.= ", priv";
$sql.= ", canvas";
$sql.= ", entity";
+ $sql.= ", import_key";
$sql.= ") VALUES (";
$sql.= "'".$this->db->idate($now)."',";
if ($this->socid > 0) $sql.= " ".$this->socid.",";
@@ -136,7 +137,8 @@ class Contact extends CommonObject
$sql.= " ".($user->id > 0 ? "'".$user->id."'":"null").",";
$sql.= " ".$this->priv.",";
$sql.= " ".($this->canvas?"'".$this->canvas."'":"null").",";
- $sql.= " ".$conf->entity;
+ $sql.= " ".$conf->entity.",";
+ $sql.= " ".$this->import_key;
$sql.= ")";
dol_syslog(get_class($this)."::create sql=".$sql);
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 2e28c7e2a5c..3027eb22026 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -361,7 +361,7 @@ else
$object->state_id = $_POST["state_id"];
// We set country_id, country_code and label for the selected country
- $object->country_id=$_POST["country_id"]?$_POST["country_id"]:(empty($objsoc->country_id)?$mysoc->country_id:$objsoc->country_id);
+ $object->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
if ($object->country_id)
{
$tmparray=getCountry($object->country_id,'all');
@@ -434,7 +434,7 @@ else
$colspan=3;
if ($conf->use_javascript_ajax && $socid > 0) $colspan=2;
-
+
// Address
if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address; // Predefined with third party
print ''.$langs->trans("Address");
@@ -442,9 +442,9 @@ else
if ($conf->use_javascript_ajax && $socid > 0)
{
- $rowspan=3;
+ $rowspan=3;
if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++;
-
+
print ' ';
print ''.$langs->trans('CopyAddressFromSoc').' ';
print ' ';
@@ -460,6 +460,7 @@ else
print ' ';
// Country
+ if (dol_strlen(trim($object->fk_pays)) == 0) $object->fk_pays = $objsoc->country_id; // Predefined with third party
print ''.$langs->trans("Country").' ';
print $form->select_country((isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id),'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index eb1c4c9e435..600bd44d95c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -221,16 +221,14 @@ abstract class CommonObject
* @param int $rowid Id of line contact-element
* @param int $statut New status of link
* @param int $type_contact_id Id of contact type (not modified if 0)
- * @param int $fk_socpeople Id of soc_people to update (not modified if 0)
* @return int <0 if KO, >= 0 if OK
*/
- function update_contact($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
+ function update_contact($rowid, $statut, $type_contact_id=0)
{
// Insertion dans la base
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
$sql.= " statut = ".$statut;
if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'";
- if ($fk_socpeople) $sql.= ", fk_socpeople = '".$fk_socpeople ."'";
$sql.= " where rowid = ".$rowid;
$resql=$this->db->query($sql);
if ($resql)
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 671334982e9..cf3c7b8ba96 100755
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -170,7 +170,7 @@ class HookManager
if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints;
// TODO. remove this. array result must be set into $actionclassinstance->results
- if (is_array($result)) $this->resArray = array_merge($this->resArray, $result);
+ if (is_array($result)) $this->resArray = array_merge($this->resArray, $result);
// TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string
if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result;
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index f031750cb5b..d2afb9a8633 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -165,10 +165,6 @@ class Form
{
$ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname);
}
- else if ($typeofdata == 'datehourpicker')
- {
- $ret.=$this->form_date($_SERVER['PHP_SELF'].'?id='.$object->id,$value,$htmlname,1,1);
- }
else if (preg_match('/^select;/',$typeofdata))
{
$arraydata=explode(',',preg_replace('/^select;/','',$typeofdata));
@@ -187,7 +183,7 @@ class Form
$ret.=$doleditor->Create(1);
}
$ret.=' ';
- if ($typeofdata != 'day' && $typeofdata != 'datepicker' && $typeofdata != 'datehourpicker') $ret.=' ';
+ if ($typeofdata != 'day' && $typeofdata != 'datepicker') $ret.=' ';
$ret.=' '."\n";
$ret.=''."\n";
}
@@ -196,7 +192,6 @@ class Form
if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1);
elseif (preg_match('/^text/',$typeofdata) || preg_match('/^note/',$typeofdata)) $ret.=dol_htmlentitiesbr($value);
elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day');
- elseif ($typeofdata == 'datehourpicker') $ret.=dol_print_date($value,'dayhour');
else if (preg_match('/^select;/',$typeofdata))
{
$arraydata=explode(',',preg_replace('/^select;/','',$typeofdata));
@@ -277,7 +272,7 @@ class Form
if (! empty($tmp[1])) $inputOption=$tmp[1];
if (! empty($tmp[2])) $savemethod=$tmp[2];
}
- else if ((preg_match('/^datepicker/',$inputType)) || (preg_match('/^datehourpicker/',$inputType)))
+ else if (preg_match('/^datepicker/',$inputType))
{
$tmp=explode(':',$inputType);
$inputType=$tmp[0];
@@ -2238,7 +2233,7 @@ class Form
$inputko=array();
// Clean parameters
- $newselectedchoice=empty($selectedchoice)?"no":$selectedchoice;
+ $newselectedchoice=empty($selectedchoice)?"no":$selectedchoice;
if (is_array($formquestion) && ! empty($formquestion))
{
@@ -2618,11 +2613,9 @@ class Form
* @param string $page Page
* @param string $selected Date preselected
* @param string $htmlname Name of input html field
- * @param int $displayhour Display hour selector
- * @param int $displaymin Display minutes selector
* @return void
*/
- function form_date($page, $selected, $htmlname,$displayhour=0,$displaymin=0)
+ function form_date($page, $selected, $htmlname)
{
global $langs;
@@ -2633,7 +2626,7 @@ class Form
print ' ';
print '';
print '';
- print $this->select_date($selected,$htmlname,$displayhour,$displaymin,1,'form'.$htmlname);
+ print $this->select_date($selected,$htmlname,0,0,1,'form'.$htmlname);
print ' ';
print ' ';
print '
';
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 5916159bd6e..09213bdd0b9 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -144,10 +144,10 @@ class FormActions
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
- $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement);
- if (is_numeric($listofactions) && $listofactions < 0) dol_print_error($this->db,'FailedToGetActions');
+ $actioncomm = new ActionComm($this->db);
+ $actioncomm->getActions($socid, $object->id, $typeelement);
- $num = count($listofactions);
+ $num = count($actioncomm->actions);
if ($num)
{
if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill');
@@ -164,29 +164,17 @@ class FormActions
$total = 0; $var=true;
print '';
- print '';
- print ''.$langs->trans('Ref').' ';
- print ''.$langs->trans('Action').' ';
- print ''.$langs->trans('Date').' ';
- print ''.$langs->trans('By').' ';
- print ' ';
+ print ''.$langs->trans('Ref').' '.$langs->trans('Date').' '.$langs->trans('Action').' '.$langs->trans('By').' ';
print "\n";
- $userstatic = new User($this->db);
-
- foreach($listofactions as $action)
+ foreach($actioncomm->actions as $action)
{
- $savlabel=$action->label;
- $action->label=$action->ref;
- $ref=$action->getNomUrl(1);
- $action->label=$savlabel;
- $label=$action->getNomUrl(0,38);
-
$var=!$var;
print '';
- print ''.$ref.' ';
- print ''.$label.' ';
+ print ''.$action->getNomUrl(1).' ';
print ''.dol_print_date($action->datep,'day').' ';
+ print ''.dol_trunc($action->label,32).' ';
+ $userstatic = new User($this->db);
$userstatic->id = $action->author->id;
$userstatic->firstname = $action->author->firstname;
$userstatic->lastname = $action->author->lastname;
@@ -206,10 +194,9 @@ class FormActions
* @param string $selected Type pre-selectionne
* @param string $htmlname Nom champ formulaire
* @param string $excludetype Type to exclude
- * @param string $onlyautoornot Group list by auto events or not
* @return void
*/
- function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0)
+ function select_type_actions($selected='',$htmlname='actioncode',$excludetype='')
{
global $langs,$user;
@@ -218,13 +205,12 @@ class FormActions
$caction=new CActionComm($this->db);
$form=new Form($this->db);
- // Suggest a list with manual event or all auto events
- $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
- array_unshift($arraylist,' '); // Add empty line at start
- //asort($arraylist);
+ $arraylist=$caction->liste_array(1, 'code', $excludetype);
+ array_unshift($arraylist,' '); // Add empty line at start
+ //asort($arraylist);
print $form->selectarray($htmlname, $arraylist, $selected);
- if ($user->admin && empty($onlyautoornot)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+ if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
}
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index ae43f9f34e7..d454cc3d005 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -143,9 +143,6 @@ class Translate
* If data for file already loaded, do nothing.
* All data in translation array are stored in UTF-8 format.
* tab_loaded is completed with $domain key.
- * Warning: MAIN_USE_CUSTOM_TRANSLATION is an old deprecated feature. Do not use it. It will revert
- * rule "we keep first entry found with we keep last entry found" so it is probably not what you want to do.
- *
* Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache
*
* @param string $domain File name to load (.lang file). Must be "file" or "file@module" for module language files:
@@ -201,14 +198,13 @@ class Translate
// Directory of translation files
$file_lang = $searchdir.($modulename?'/'.$modulename:'')."/langs/".$langofdir."/".$newdomain.".lang";
$file_lang_osencoded=dol_osencode($file_lang);
-
$filelangexists=is_file($file_lang_osencoded);
//dol_syslog('Translate::Load Try to read for alt='.$alt.' langofdir='.$langofdir.' file_lang='.$file_lang." => filelangexists=".$filelangexists);
if ($filelangexists)
{
- // TODO Move cache read out of loop on dirs or at least filelangexists
+ // TODO Move cache read out of loop on dirs
$found=false;
// Enable caching of lang file in memory (not by default)
diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js
index d03baa648c4..d9088ba83ba 100644
--- a/htdocs/core/js/lib_head.js
+++ b/htdocs/core/js/lib_head.js
@@ -729,7 +729,6 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
modal: true,
buttons: [
{
- id : 'yesButton_' + code,
text : yesButton,
click : function() {
if (action == "set") {
@@ -749,7 +748,6 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
}
},
{
- id : 'noButton_' + code,
text : noButton,
click : function() {
$(this).dialog("close");
@@ -757,10 +755,6 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
}
]
});
- // For information dialog box only, hide the noButton
- if (boxConfirm.info) {
- $("#noButton_" + code).button().hide();
- }
}
/*
diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php
index a44c45128c1..dba22075612 100644
--- a/htdocs/core/lib/agenda.lib.php
+++ b/htdocs/core/lib/agenda.lib.php
@@ -93,10 +93,7 @@ function print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirt
print '';
print $langs->trans("Type");
print ' ';
-
- // print $formactions->select_type_actions(GETPOST('actioncode'), "actioncode");
- print $formactions->select_type_actions(GETPOST('actioncode')?GETPOST('actioncode'):'manual', "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0));
-
+ print $formactions->select_type_actions(GETPOST('actioncode'), "actioncode");
print ' ';
}
@@ -443,11 +440,9 @@ function calendars_prepare_head($param)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'agenda');
- complete_head_from_modules($conf,$langs,$object,$head,$h,'agenda','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index ba9511d8d66..4b5b4f986ce 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -375,11 +375,6 @@ function ajax_constantonoff($code, $input=array(), $entity=false)
// Set constant
$("#set_" + code).click(function() {
if (input.alert && input.alert.set) {
- // Posibility to force label of buttons
- if (input.alert.set.yesButton)
- yesButton = input.alert.set.yesButton;
- if (input.alert.set.noButton)
- noButton = input.alert.set.noButton;
confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton);
} else {
setConstant(url, code, input, entity);
@@ -389,11 +384,6 @@ function ajax_constantonoff($code, $input=array(), $entity=false)
// Del constant
$("#del_" + code).click(function() {
if (input.alert && input.alert.del) {
- // Posibility to force label of buttons
- if (input.alert.del.yesButton)
- yesButton = input.alert.del.yesButton;
- if (input.alert.del.noButton)
- noButton = input.alert.del.noButton;
confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton);
} else {
delConstant(url, code, input, entity);
diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php
index c330e55a388..ba3f0de1145 100644
--- a/htdocs/core/lib/categories.lib.php
+++ b/htdocs/core/lib/categories.lib.php
@@ -51,11 +51,9 @@ function categories_prepare_head($object,$type)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type);
- complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type,'remove');
-
return $head;
}
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 8ddf40e2abf..a5fe3c5d1f2 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -777,7 +777,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0)
if (get_class($object) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m";
if (get_class($object) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " WHERE u.rowid = a.fk_user_author";
- $sql.= " AND a.entity IN (".getEntity('agenda', 1).")";
+ $sql.= " AND a.entity IN (".getEntity('actioncomm').")";
if (get_class($object) == 'Adherent') {
$sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
if (! empty($object->id))
@@ -916,7 +916,7 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0)
if (get_class($object) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m";
if (get_class($object) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " WHERE u.rowid = a.fk_user_author";
- $sql.= " AND a.entity IN (".getEntity('agenda', 1).")";
+ $sql.= " AND a.entity IN (".getEntity('actioncomm').")";
if (get_class($object) == 'Adherent') $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
if (get_class($object) == 'Adherent' && $object->id) $sql.= " AND a.fk_element = ".$object->id;
if (get_class($object) == 'Societe' && $object->id) $sql.= " AND a.fk_soc = ".$object->id;
diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php
index 2e41d7276fa..8009ba6e31d 100644
--- a/htdocs/core/lib/contact.lib.php
+++ b/htdocs/core/lib/contact.lib.php
@@ -63,7 +63,7 @@ function contact_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'contact');
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id;
@@ -71,7 +71,7 @@ function contact_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'contact','remove');
+
return $head;
}
diff --git a/htdocs/core/lib/contract.lib.php b/htdocs/core/lib/contract.lib.php
index 238bfb2a7b3..90a15cf958e 100644
--- a/htdocs/core/lib/contract.lib.php
+++ b/htdocs/core/lib/contract.lib.php
@@ -38,7 +38,7 @@ function contract_prepare_head($object)
$head[$h][1] = $langs->trans("ContractCard");
$head[$h][2] = 'card';
$h++;
-
+
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
@@ -50,9 +50,9 @@ function contract_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
-
+
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
@@ -71,8 +71,6 @@ function contract_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php
index 463375baca0..08732c271af 100644
--- a/htdocs/core/lib/fichinter.lib.php
+++ b/htdocs/core/lib/fichinter.lib.php
@@ -42,7 +42,7 @@ function fichinter_prepare_head($object)
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
-
+
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
@@ -62,9 +62,9 @@ function fichinter_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
-
+
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
@@ -83,9 +83,7 @@ function fichinter_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove');
-
- return $head;
+ return $head;
}
?>
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index 21db6d63fb8..887cae3115d 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -52,7 +52,7 @@ function facturefourn_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
@@ -77,9 +77,7 @@ function facturefourn_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice','remove');
-
- return $head;
+ return $head;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 715d84e3067..7aa197be58f 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2703,8 +2703,9 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="")
// Some test to guess with no need to make database access
if ($mysoc->country_code == 'ES') // For spain, localtaxes are qualified if both supplier and seller use local taxe
{
- if ($local == 1 && ! $thirdparty_buyer->localtax1_assuj) return 0;
- if ($local == 2 && ! $thirdparty_seller->localtax2_assuj) return 0;
+ if ($local == 1 && (! $thirdparty_seller->localtax1_assuj || ! $thirdparty_buyer->localtax1_assuj)) return 0;
+ if ($local == 2 && (! $thirdparty_seller->localtax2_assuj || ! $thirdparty_buyer->localtax2_assuj)) return 0;
+
}
else
{
@@ -2993,27 +2994,18 @@ function get_default_npr($thirdparty_seller, $thirdparty_buyer, $idprod)
*/
function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
{
- global $mysoc;
-
if (!is_object($thirdparty_seller)) return -1;
if (!is_object($thirdparty_buyer)) return -1;
- if ($local==1) // Localtax 1
+ if ($local==1) //RE
{
- if ($mysoc->country_code == 'ES')
- {
- if (is_numeric($thirdparty_buyer->localtax1_assuj) && ! $thirdparty_buyer->localtax1_assuj) return 0;
- }
- else
- {
- // Si vendeur non assujeti a Localtax1, localtax1 par default=0
- if (is_numeric($thirdparty_seller->localtax1_assuj) && ! $thirdparty_seller->localtax1_assuj) return 0;
- if (! is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj=='localtax1off') return 0;
- }
+ // Si vendeur non assujeti a RE, localtax1 par default=0
+ if (is_numeric($thirdparty_seller->localtax1_assuj) && ! $thirdparty_seller->localtax1_assuj) return 0;
+ if (! is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj=='localtax1off') return 0;
}
- elseif ($local==2) //I Localtax 2
+ elseif ($local==2) //IRPF
{
- // Si vendeur non assujeti a Localtax2, localtax2 par default=0
+ // Si vendeur non assujeti a IRPF, localtax2 par default=0
if (is_numeric($thirdparty_seller->localtax2_assuj) && ! $thirdparty_seller->localtax2_assuj) return 0;
if (! is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj=='localtax2off') return 0;
}
@@ -4216,6 +4208,35 @@ function getCurrencySymbol($currency_code)
return $currency_sign;
}
+/**
+ * Get type of one localtax
+ *
+ * @param int $vatrate VAT Rate
+ * @param int $number Number of localtax (1 / 2)
+ * @param int $thirdparty company object
+ * @return array array(Type of local tax (1 to 7 / 0 if not found), rate or amount of localtax)
+ */
+
+function getTypeOfLocalTaxFromRate($vatrate, $number, $thirdparty)
+{
+ global $db;
+
+ // Search local taxes
+ $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
+ $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$thirdparty->country_code."'";
+ $sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
+
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($number == 1) return array($obj->localtax1_type, $obj->localtax1);
+ elseif ($number == 2) return array($obj->localtax2_type, $obj->localtax2);
+ }
+
+ return 0;
+}
if (! function_exists('getmypid'))
{
diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php
deleted file mode 100644
index 6d96d2bd1f3..00000000000
--- a/htdocs/core/lib/holiday.lib.php
+++ /dev/null
@@ -1,53 +0,0 @@
-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- * or see http://www.gnu.org/
- */
-
-/**
- * \file htdocs/core/lib/holiday.lib.php
- * \brief Ensemble de fonctions de base pour les adherents
- */
-
-/**
- * Return array head with list of tabs to view object informations
- *
- * @param Object $object Holiday
- * @return array head
- */
-function holiday_prepare_head($object)
-{
- global $langs, $conf, $user;
-
- $h = 0;
- $head = array();
-
- $head[$h][0] = DOL_URL_ROOT . '/holiday/fiche.php?id='.$object->id;
- $head[$h][1] = $langs->trans("Card");
- $head[$h][2] = 'card';
- $h++;
-
- // Show more tabs from modules
- // Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
- complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday');
-
- complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove');
-
- return $head;
-}
-
-?>
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 7fd7ab97248..8d3990942c1 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -39,7 +39,7 @@ function facture_prepare_head($object)
$head[$h][1] = $langs->trans('CardBill');
$head[$h][2] = 'compta';
$h++;
-
+
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
@@ -68,9 +68,9 @@ function facture_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
-
+
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
@@ -93,8 +93,6 @@ function facture_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index 835708295c3..88e740c1245 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -183,11 +183,9 @@ function member_stats_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
- complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats','remove');
-
return $head;
}
?>
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index f5c8b41f0ec..3fc1bc73f04 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -67,7 +67,7 @@ function commande_prepare_head($object)
$head[$h][2] = 'preview';
$h++;
}
-
+
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
@@ -79,7 +79,7 @@ function commande_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
@@ -90,7 +90,7 @@ function commande_prepare_head($object)
$head[$h][1] = $langs->trans('Documents');
$head[$h][2] = 'documents';
$h++;
-
+
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
@@ -104,9 +104,7 @@ function commande_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
-
- return $head;
+ return $head;
}
?>
diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php
index 2b4f6264068..c370172430a 100644
--- a/htdocs/core/lib/prelevement.lib.php
+++ b/htdocs/core/lib/prelevement.lib.php
@@ -75,11 +75,9 @@ function prelevement_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'prelevement');
- complete_head_from_modules($conf,$langs,$object,$head,$h,'prelevement','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index ee547ca49d7..cb345399733 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -113,7 +113,7 @@ function product_prepare_head($object, $user)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'product');
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id;
@@ -158,8 +158,8 @@ function product_admin_prepare_head($object=null)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'product_admin');
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php';
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 6265ecdb52b..c051649fb44 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -61,7 +61,7 @@ function project_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'project');
$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
@@ -96,9 +96,7 @@ function project_prepare_head($object)
$head[$h][2] = 'gantt';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove');
-
- return $head;
+ return $head;
}
@@ -132,7 +130,7 @@ function task_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');;
@@ -149,8 +147,6 @@ function task_prepare_head($object)
$head[$h][2] = 'task_notes';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php
index 9c44b578f14..a0922fc4c4c 100644
--- a/htdocs/core/lib/propal.lib.php
+++ b/htdocs/core/lib/propal.lib.php
@@ -73,7 +73,7 @@ function propal_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
@@ -98,8 +98,6 @@ function propal_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php
index 5ba774d1b3e..d031bdd167c 100644
--- a/htdocs/core/lib/sendings.lib.php
+++ b/htdocs/core/lib/sendings.lib.php
@@ -66,12 +66,10 @@ function shipping_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
- complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
-
return $head;
}
@@ -107,12 +105,10 @@ function delivery_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
- complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/stock.lib.php b/htdocs/core/lib/stock.lib.php
index 22694c39217..7fb81297cb3 100644
--- a/htdocs/core/lib/stock.lib.php
+++ b/htdocs/core/lib/stock.lib.php
@@ -66,7 +66,7 @@ function stock_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'stock');
$head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id;
@@ -74,9 +74,7 @@ function stock_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'stock','remove');
-
- return $head;
+ return $head;
}
?>
\ No newline at end of file
diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php
index 96ae34899fb..eab91d27d4b 100644
--- a/htdocs/core/lib/tax.lib.php
+++ b/htdocs/core/lib/tax.lib.php
@@ -45,7 +45,7 @@ function tax_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'tax');
$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id;
@@ -58,8 +58,6 @@ function tax_prepare_head($object)
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'tax','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/trip.lib.php b/htdocs/core/lib/trip.lib.php
index e0380e6ef55..d2c150cf7da 100644
--- a/htdocs/core/lib/trip.lib.php
+++ b/htdocs/core/lib/trip.lib.php
@@ -33,25 +33,23 @@ function trip_prepare_head($object)
$h = 0;
$head = array();
-
+
$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/fiche.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
-
+
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'trip');
-
+
$head[$h][0] = DOL_URL_ROOT . '/compta/deplacement/info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
- complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove');
-
return $head;
}
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index a4e6a9623c5..7c484b5c923 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -81,8 +81,8 @@ function user_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:conditiontoshow:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:conditiontoshow:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
if (! empty($user->societe_id))
@@ -98,8 +98,6 @@ function user_prepare_head($object)
$h++;
}
- complete_head_from_modules($conf,$langs,$object,$head,$h,'user','remove');
-
return $head;
}
@@ -142,11 +140,9 @@ function group_prepare_head($object)
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'group');
- complete_head_from_modules($conf,$langs,$object,$head,$h,'group','remove');
-
return $head;
}
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 60d28a6c07b..95d92015841 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -1,1238 +1,1247 @@
-
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2008 Raphael Bertrand
- * Copyright (C) 2010-2012 Juanjo Menent
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- * or see http://www.gnu.org/
- */
-
-/**
- * \file htdocs/core/modules/commande/doc/pdf_einstein.modules.php
- * \ingroup commande
- * \brief Fichier de la classe permettant de generer les commandes au modele Einstein
- */
-
-require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
-require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
-
-
-/**
- * Classe permettant de generer les commandes au modele Einstein
- */
-class pdf_einstein extends ModelePDFCommandes
-{
- var $db;
- var $name;
- var $description;
- var $type;
-
- var $phpmin = array(4,3,0); // Minimum version of PHP required by module
- var $version = 'dolibarr';
-
- var $page_largeur;
- var $page_hauteur;
- var $format;
- var $marge_gauche;
- var $marge_droite;
- var $marge_haute;
- var $marge_basse;
-
- var $emetteur; // Objet societe qui emet
-
-
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- function __construct($db)
- {
- global $conf,$langs,$mysoc;
-
- $langs->load("main");
- $langs->load("bills");
-
- $this->db = $db;
- $this->name = "einstein";
- $this->description = $langs->trans('PDFEinsteinDescription');
-
- // Dimension page pour format A4
- $this->type = 'pdf';
- $formatarray=pdf_getFormat();
- $this->page_largeur = $formatarray['width'];
- $this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
-
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 0; // Affiche si il y a eu escompte
- $this->option_credit_note = 0; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
-
- // Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
-
- // Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
- $this->posxtva=111;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxdiscount=162;
- $this->postotalht=174;
- if ($this->page_largeur < 210) // To work with US executive format
- {
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
- }
-
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->localtax1_type=array();
- $this->localtax2_type=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
- }
-
- /**
- * Function to build pdf onto disk
- *
- * @param Object $object Object to generate
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @param object $hookmanager Hookmanager object
- * @return int 1=OK, 0=KO
- */
- function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
- {
- global $user,$langs,$conf;
-
- if (! is_object($outputlangs)) $outputlangs=$langs;
- // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
-
- $outputlangs->load("main");
- $outputlangs->load("dict");
- $outputlangs->load("companies");
- $outputlangs->load("bills");
- $outputlangs->load("products");
- $outputlangs->load("orders");
-
- if ($conf->commande->dir_output)
- {
- $object->fetch_thirdparty();
-
- $deja_regle = "";
-
- // Definition of $dir and $file
- if ($object->specimen)
- {
- $dir = $conf->commande->dir_output;
- $file = $dir . "/SPECIMEN.pdf";
- }
- else
- {
- $objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->commande->dir_output . "/" . $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
- }
-
- if (! file_exists($dir))
- {
- if (dol_mkdir($dir) < 0)
- {
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
- return 0;
- }
- }
-
- if (file_exists($dir))
- {
- $nblignes = count($object->lines);
-
- // Create pdf instance
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 50; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- $pdf->SetAutoPageBreak(1,0);
-
- if (class_exists('TCPDF'))
- {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
- // Set path to the background PDF File
- if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
- $tplidx = $pdf->importPage(1);
- }
-
- $pdf->Open();
- $pagenb=0;
- $pdf->SetDrawColor(128,128,128);
-
- $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
- $pdf->SetSubject($outputlangs->transnoentities("Order"));
- $pdf->SetCreator("Dolibarr ".DOL_VERSION);
- $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
-
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
-
- // Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblignes ; $i++)
- {
- if ($object->lines[$i]->remise_percent)
- {
- $this->atleastonediscount++;
- }
- }
-
- // New page
- $pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- $pagenb++;
- $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
- $pdf->SetTextColor(0,0,0);
-
-
- $tab_top = 90;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
- $tab_height = 130;
- $tab_height_newpage = 150;
-
- // Affiche notes
- if (! empty($object->note_public))
- {
- $tab_top = 88;
-
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
- $nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
-
- // Rect prend une longueur en 3eme param
- $pdf->SetDrawColor(192,192,192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
-
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
- }
-
- $iniY = $tab_top + 7;
- $curY = $tab_top + 7;
- $nexY = $tab_top + 7;
-
- // Loop on each lines
- for ($i = 0 ; $i < $nblignes ; $i++)
- {
- $curY = $nexY;
- $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
- $pdf->SetTextColor(0,0,0);
-
- $pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
-
- // Description of product line
- $curX = $this->posxdesc-1;
-
- $showpricebeforepagebreak=1;
-
- $pdf->startTransaction();
- pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
- $pageposafter=$pdf->getPage();
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
- $pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
- //print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
- pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
- {
- if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
- {
- $pdf->AddPage('','',true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
- $pdf->setPage($pagenb+1);
- }
- }
- else
- {
- // We found a page break
- $showpricebeforepagebreak=0;
- }
- }
- else // No pagebreak
- {
- $pdf->commitTransaction();
- }
-
- $nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
- $pdf->setPage($pageposbefore);
- $pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
-
- // We suppose that a too long description is moved completely on next page
- if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
- $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
- }
-
- $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
-
- // VAT Rate
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $pdf->SetXY($this->posxtva, $curY);
- $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
- }
-
- // Unit price before discount
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $pdf->SetXY($this->posxup, $curY);
- $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0);
-
- // Quantity
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars
-
- // Discount on line
- if ($object->lines[$i]->remise_percent)
- {
- $pdf->SetXY($this->posxdiscount-2, $curY);
- $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
- }
-
- // Total HT line
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $pdf->SetXY($this->postotalht, $curY);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
-
- // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- $tvaligne=$object->lines[$i]->total_tva;
-
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
-
- if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
-
- $vatrate=(string) $object->lines[$i]->tva_tx;
-
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
- $this->tva[$vatrate] += $tvaligne;
-
- // Search local taxes
- $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
- $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$object->client->country_code."'";
- $sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
-
- $resqlt=$this->db->query($sql);
- if ($resqlt)
- {
- $objt = $this->db->fetch_object($resqlt);
- $this->localtax1[$objt->localtax1_type][$objt->localtax1]+=$localtax1ligne;
- $this->localtax2[$objt->localtax2_type][$objt->localtax2]+=$localtax2ligne;
- }
-
- // Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
- {
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
- //$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
- $pdf->SetLineStyle(array('dash'=>0));
- }
-
- $nexY+=2; // Passe espace entre les lignes
-
- // Detect if some page were added automatically and output _tableau for past pages
- while ($pagenb < $pageposafter)
- {
- $pdf->setPage($pagenb);
- if ($pagenb == 1)
- {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- }
- else
- {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
- }
- $this->_pagefoot($pdf,$object,$outputlangs,1);
- $pagenb++;
- $pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
- }
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
- {
- if ($pagenb == 1)
- {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- }
- else
- {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
- }
- $this->_pagefoot($pdf,$object,$outputlangs,1);
- // New page
- $pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- $pagenb++;
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
- }
- }
-
- // Show square
- if ($pagenb == 1)
- {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- }
- else
- {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- }
-
- // Affiche zone infos
- $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
-
- // Affiche zone totaux
- $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
-
- // Affiche zone versements
- if ($deja_regle)
- {
- $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
- }
-
- // Pied de page
- $this->_pagefoot($pdf,$object,$outputlangs);
- $pdf->AliasNbPages();
-
- $pdf->Close();
-
- $pdf->Output($file,'F');
-
- // Add pdfgeneration hook
- if (! is_object($hookmanager))
- {
- include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
- }
- $hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
- global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
-
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($file, octdec($conf->global->MAIN_UMASK));
-
- return 1; // Pas d'erreur
- }
- else
- {
- $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
- return 0;
- }
- }
- else
- {
- $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
- return 0;
- }
- $this->error=$langs->trans("ErrorUnknown");
- return 0; // Erreur par defaut
- }
-
- /**
- * Show payments table
- *
- * @param PDF &$pdf Object PDF
- * @param Object $object Object order
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @return int <0 if KO, >0 if OK
- */
- function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
- {
-
- }
-
-
- /**
- * Show miscellaneous information (payment mode, payment term, ...)
- *
- * @param PDF &$pdf Object PDF
- * @param Object $object Object to show
- * @param int $posy Y
- * @param Translate $outputlangs Langs object
- * @return void
- */
- function _tableau_info(&$pdf, $object, $posy, $outputlangs)
- {
- global $conf;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- $pdf->SetFont('','', $default_font_size - 1);
-
- // If France, show VAT mention if not applicable
- if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
-
- $posy=$pdf->GetY()+4;
- }
-
- $posxval=52;
-
- // Show payments conditions
- if ($object->cond_reglement_code || $object->cond_reglement)
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentConditions").':';
- $pdf->MultiCell(80, 4, $titre, 0, 'L');
-
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
- $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
- $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
-
- $posy=$pdf->GetY()+3;
- }
-
- // Check a payment mode is defined
- /* Not used with orders
- if (empty($object->mode_reglement_code)
- && ! $conf->global->FACTURE_CHQ_NUMBER
- && ! $conf->global->FACTURE_RIB_NUMBER)
- {
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
- $pdf->SetTextColor(0,0,0);
-
- $posy=$pdf->GetY()+1;
- }
- */
-
- // Show payment mode
- if ($object->mode_reglement_code
- && $object->mode_reglement_code != 'CHQ'
- && $object->mode_reglement_code != 'VIR')
- {
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentMode").':';
- $pdf->MultiCell(80, 5, $titre, 0, 'L');
-
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
- $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
-
- $posy=$pdf->GetY()+2;
- }
-
- // Show payment mode CHQ
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
- {
- // Si mode reglement non force ou si force a CHQ
- if (! empty($conf->global->FACTURE_CHQ_NUMBER))
- {
- if ($conf->global->FACTURE_CHQ_NUMBER > 0)
- {
- $account = new Account($this->db);
- $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
-
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetFont('','B', $default_font_size - 3);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
- $posy=$pdf->GetY()+1;
-
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetFont('','', $default_font_size - 3);
- $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
- }
- if ($conf->global->FACTURE_CHQ_NUMBER == -1)
- {
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetFont('','B', $default_font_size - 3);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
- $posy=$pdf->GetY()+1;
-
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetFont('','', $default_font_size - 3);
- $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
- }
- }
- }
- }
-
- // If payment mode not forced or forced to VIR, show payment with BAN
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
- {
- if (! empty($conf->global->FACTURE_RIB_NUMBER))
- {
- $account = new Account($this->db);
- $account->fetch($conf->global->FACTURE_RIB_NUMBER);
-
- $curx=$this->marge_gauche;
- $cury=$posy;
-
- $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
-
- $posy+=2;
- }
- }
-
- return $posy;
- }
-
-
- /**
- * Show total to pay
- *
- * @param PDF &$pdf Object PDF
- * @param Facture $object Object invoice
- * @param int $deja_regle Montant deja regle
- * @param int $posy Position depart
- * @param Translate $outputlangs Objet langs
- * @return int Position pour suite
- */
- function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
- {
- global $conf,$mysoc;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- $tab2_top = $posy;
- $tab2_hl = 4;
- $pdf->SetFont('','', $default_font_size - 1);
-
- // Tableau total
- $col1x = 120; $col2x = 170;
- if ($this->page_largeur < 210) // To work with US executive format
- {
- $col2x-=20;
- }
- $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
-
- $useborder=0;
- $index = 0;
-
- // Total HT
- $pdf->SetFillColor(255,255,255);
- $pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
-
- // Show VAT by rates and total
- $pdf->SetFillColor(248,248,248);
-
- $this->atleastoneratenotnull=0;
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
- {
- // Nothing to do
- }
- else
- {
- //Local tax 1 before VAT
- if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
- {
- foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
- switch ($localtax_type) {
- case '1':
- case '3':
- case '5':
- case '7':
- continue 2;
- break;
- }
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey>0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
- }
- }
- }
- }
- //Local tax 2 before VAT
- if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
- {
- foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
- switch ($localtax_type) {
- case '1':
- case '3':
- case '5':
- case '7':
- continue 2;
- break;
- }
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey>0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
-
-
- $index++;
- $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
-
- }
- }
- }
- }
- // VAT
- foreach($this->tva as $tvakey => $tvaval)
- {
- if ($tvakey > 0) // On affiche pas taux 0
- {
- $this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
- }
- }
-
- //Local tax 1 after VAT
- if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
- {
- foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
- switch ($localtax_type) {
- case '2':
- case '4':
- case '6':
- continue 2;
- break;
- }
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey>0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
- if ($localtax_type == '7') { // amount on order
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
- }
- else
- {
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
- }
- }
- }
- }
- }
- //Local tax 2 after VAT
- if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
- {
- foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
- switch ($localtax_type) {
- case '2':
- case '4':
- case '6':
- continue 2;
- break;
- }
- foreach( $localtax_rate as $tvakey => $tvaval )
- {
- if ($tvakey>0) // On affiche pas taux 0
- {
- //$this->atleastoneratenotnull++;
-
- $index++;
- $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
-
- $tvacompl='';
- if (preg_match('/\*/',$tvakey))
- {
- $tvakey=str_replace('*','',$tvakey);
- $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
- }
- $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
-
- if ($localtax_type == '7') { // amount on order
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
- }
- else
- {
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
-
- $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
- }
- }
- }
- }
- }
-
- // Total TTC
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
- }
- }
-
- $pdf->SetTextColor(0,0,0);
-
- $creditnoteamount=0;
- $depositsamount=0;
- //$creditnoteamount=$object->getSumCreditNotesUsed();
- //$depositsamount=$object->getSumDepositsUsed();
- //print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
- if (! empty($object->paye)) $resteapayer=0;
-
- if ($deja_regle > 0)
- {
- // Already paid + Deposits
- $index++;
-
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
-
- $index++;
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFillColor(224,224,224);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
-
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
-
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetTextColor(0,0,0);
- }
-
- $index++;
- return ($tab2_top + ($tab2_hl * $index));
- }
-
- /**
- * Show table for lines
- *
- * @param PDF &$pdf Object PDF
- * @param string $tab_top Top position of table
- * @param string $tab_height Height of table (rectangle)
- * @param int $nexY Y (not used)
- * @param Translate $outputlangs Langs object
- * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
- * @param int $hidebottom Hide bottom bar of array
- * @return void
- */
- function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
- {
- global $conf;
-
- // Force to disable hidetop and hidebottom
- $hidebottom=0;
- if ($hidetop) $hidetop=-1;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- // Amount in (at tab_top - 1)
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
-
- if (empty($hidetop))
- {
- $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
- $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
- }
-
- $pdf->SetDrawColor(128,128,128);
- $pdf->SetFont('','', $default_font_size - 1);
-
- // Output Rect
- $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
-
- if (empty($hidetop))
- {
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
-
- $pdf->SetXY($this->posxdesc-1, $tab_top+1);
- $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
- }
-
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
- {
- $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxtva-3, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
- }
- }
-
- $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
- }
-
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
- }
-
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
- if ($this->atleastonediscount)
- {
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
- }
- }
-
- if ($this->atleastonediscount)
- {
- $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
- }
- if (empty($hidetop))
- {
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
- $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
- }
- }
-
- /**
- * Show top header of page.
- *
- * @param PDF &$pdf Object PDF
- * @param Object $object Object to show
- * @param int $showaddress 0=no, 1=yes
- * @param Translate $outputlangs Object lang for output
- * @param object $hookmanager Hookmanager object
- * @return void
- */
- function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
- {
- global $conf,$langs;
-
- $outputlangs->load("main");
- $outputlangs->load("bills");
- $outputlangs->load("propal");
- $outputlangs->load("companies");
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
-
- // Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
- {
- pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
- }
-
- $pdf->SetTextColor(0,0,60);
- $pdf->SetFont('','B', $default_font_size + 3);
-
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
-
- $pdf->SetXY($this->marge_gauche,$posy);
-
- // Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
- if ($this->emetteur->logo)
- {
- if (is_readable($logo))
- {
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- }
- else
- {
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B', $default_font_size -2);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
- }
- }
- else
- {
- $text=$this->emetteur->name;
- $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
- }
-
- $pdf->SetFont('','B', $default_font_size + 3);
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $title=$outputlangs->transnoentities("Order");
- $pdf->MultiCell(100, 3, $title, '', 'R');
-
- $pdf->SetFont('','B',$default_font_size);
-
- $posy+=5;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
-
- $posy+=1;
- $pdf->SetFont('','', $default_font_size - 1);
-
- if ($object->ref_client)
- {
- $posy+=5;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
- }
-
- $posy+=4;
- $pdf->SetXY($posx,$posy);
- $pdf->SetTextColor(0,0,60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
-
- $posy+=2;
-
- // Show list of linked objects
- $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
-
- if ($showaddress)
- {
- // Sender properties
- $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
-
- // Show sender
- $posy=42;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
-
- // Show sender frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx,$posy-5);
- $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
- $pdf->SetXY($posx,$posy);
- $pdf->SetFillColor(230,230,230);
- $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0,0,60);
-
- // Show sender name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
-
- // Show sender information
- $pdf->SetXY($posx+2,$posy+8);
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
-
-
-
- // If CUSTOMER contact defined on order, we use it
- $usecontact=false;
- $arrayidcontact=$object->getIdContact('external','CUSTOMER');
- if (count($arrayidcontact) > 0)
- {
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
- }
-
- // Recipient name
- if (! empty($usecontact))
- {
- // On peut utiliser le nom de la societe du contact
- if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
- else $socname = $object->client->nom;
- $carac_client_name=$outputlangs->convToOutputCharset($socname);
- }
- else
- {
- $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
- }
-
- $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
-
- // Show recipient
- $widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
-
- // Show recipient frame
- $pdf->SetTextColor(0,0,0);
- $pdf->SetFont('','', $default_font_size - 2);
- $pdf->SetXY($posx+2,$posy-5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
-
- // Show recipient name
- $pdf->SetXY($posx+2,$posy+3);
- $pdf->SetFont('','B', $default_font_size);
- $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
-
- // Show recipient information
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
- }
- }
-
- /**
- * Show footer of page. Need this->emetteur object
- *
- * @param PDF &$pdf PDF
- * @param Object $object Object to show
- * @param Translate $outputlangs Object lang for output
- * @param int $hidefreetext 1=Hide free text
- * @return int Return height of bottom margin including footer text
- */
- function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
- {
- return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext);
- }
-
-}
-
-?>
+
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2008 Raphael Bertrand
+ * Copyright (C) 2010-2012 Juanjo Menent
+ * Copyright (C) 2012 Christophe Battarel
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+ * \ingroup commande
+ * \brief Fichier de la classe permettant de generer les commandes au modele Einstein
+ */
+
+require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+
+
+/**
+ * Classe permettant de generer les commandes au modele Einstein
+ */
+class pdf_einstein extends ModelePDFCommandes
+{
+ var $db;
+ var $name;
+ var $description;
+ var $type;
+
+ var $phpmin = array(4,3,0); // Minimum version of PHP required by module
+ var $version = 'dolibarr';
+
+ var $page_largeur;
+ var $page_hauteur;
+ var $format;
+ var $marge_gauche;
+ var $marge_droite;
+ var $marge_haute;
+ var $marge_basse;
+
+ var $emetteur; // Objet societe qui emet
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ function __construct($db)
+ {
+ global $conf,$langs,$mysoc;
+
+ $langs->load("main");
+ $langs->load("bills");
+
+ $this->db = $db;
+ $this->name = "einstein";
+ $this->description = $langs->trans('PDFEinsteinDescription');
+
+ // Dimension page pour format A4
+ $this->type = 'pdf';
+ $formatarray=pdf_getFormat();
+ $this->page_largeur = $formatarray['width'];
+ $this->page_hauteur = $formatarray['height'];
+ $this->format = array($this->page_largeur,$this->page_hauteur);
+ $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
+ $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
+ $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
+ $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+
+ $this->option_logo = 1; // Affiche logo
+ $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Affiche mode reglement
+ $this->option_condreg = 1; // Affiche conditions reglement
+ $this->option_codeproduitservice = 1; // Affiche code produit-service
+ $this->option_multilang = 1; // Dispo en plusieurs langues
+ $this->option_escompte = 0; // Affiche si il y a eu escompte
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
+
+ $this->franchise=!$mysoc->tva_assuj;
+
+ // Get source company
+ $this->emetteur=$mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
+
+ // Define position of columns
+ $this->posxdesc=$this->marge_gauche+1;
+ $this->posxtva=111;
+ $this->posxup=126;
+ $this->posxqty=145;
+ $this->posxdiscount=162;
+ $this->postotalht=174;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $this->posxtva-=20;
+ $this->posxup-=20;
+ $this->posxqty-=20;
+ $this->posxdiscount-=20;
+ $this->postotalht-=20;
+ }
+
+ $this->tva=array();
+ $this->localtax1=array();
+ $this->localtax2=array();
+ $this->atleastoneratenotnull=0;
+ $this->atleastonediscount=0;
+ }
+
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param Object $object Object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @param object $hookmanager Hookmanager object
+ * @return int 1=OK, 0=KO
+ */
+ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
+ {
+ global $user,$langs,$conf,$mysoc,$db;
+
+ if (! is_object($outputlangs)) $outputlangs=$langs;
+ // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+ if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+
+ $outputlangs->load("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+ $outputlangs->load("products");
+ $outputlangs->load("orders");
+
+ if ($conf->commande->dir_output)
+ {
+ $object->fetch_thirdparty();
+
+ $deja_regle = "";
+
+ // Definition of $dir and $file
+ if ($object->specimen)
+ {
+ $dir = $conf->commande->dir_output;
+ $file = $dir . "/SPECIMEN.pdf";
+ }
+ else
+ {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->commande->dir_output . "/" . $objectref;
+ $file = $dir . "/" . $objectref . ".pdf";
+ }
+
+ if (! file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
+ $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
+ return 0;
+ }
+ }
+
+ if (file_exists($dir))
+ {
+ $nblignes = count($object->lines);
+
+ // Create pdf instance
+ $pdf=pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ $pdf->SetAutoPageBreak(1,0);
+
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ // Set path to the background PDF File
+ if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
+
+ $pdf->Open();
+ $pagenb=0;
+ $pdf->SetDrawColor(128,128,128);
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("Order"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order"));
+ if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+
+ // Positionne $this->atleastonediscount si on a au moins une remise
+ for ($i = 0 ; $i < $nblignes ; $i++)
+ {
+ if ($object->lines[$i]->remise_percent)
+ {
+ $this->atleastonediscount++;
+ }
+ }
+
+ // New page
+ $pdf->AddPage();
+ if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pagenb++;
+ $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager);
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->SetTextColor(0,0,0);
+
+
+ $tab_top = 90;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
+ $tab_height = 130;
+ $tab_height_newpage = 150;
+
+ // Affiche notes
+ if (! empty($object->note_public))
+ {
+ $tab_top = 88;
+
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $nexY = $pdf->GetY();
+ $height_note=$nexY-$tab_top;
+
+ // Rect prend une longueur en 3eme param
+ $pdf->SetDrawColor(192,192,192);
+ $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+
+ $tab_height = $tab_height - $height_note;
+ $tab_top = $nexY+6;
+ }
+ else
+ {
+ $height_note=0;
+ }
+
+ $iniY = $tab_top + 7;
+ $curY = $tab_top + 7;
+ $nexY = $tab_top + 7;
+
+ // Loop on each lines
+ for ($i = 0 ; $i < $nblignes ; $i++)
+ {
+ $curY = $nexY;
+ $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetTextColor(0,0,0);
+
+ $pdf->setTopMargin($tab_top_newpage);
+ $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore=$pdf->getPage();
+
+ // Description of product line
+ $curX = $this->posxdesc-1;
+
+ $showpricebeforepagebreak=1;
+
+ $pdf->startTransaction();
+ pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
+ $pageposafter=$pdf->getPage();
+ if ($pageposafter > $pageposbefore) // There is a pagebreak
+ {
+ $pdf->rollbackTransaction(true);
+ $pageposafter=$pageposbefore;
+ //print $pageposafter.'-'.$pageposbefore;exit;
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
+ $posyafter=$pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ {
+ if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
+ {
+ $pdf->AddPage('','',true);
+ if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
+ $pdf->setPage($pagenb+1);
+ }
+ }
+ else
+ {
+ // We found a page break
+ $showpricebeforepagebreak=0;
+ }
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+
+ $nexY = $pdf->GetY();
+ $pageposafter=$pdf->getPage();
+ $pdf->setPage($pageposbefore);
+ $pdf->setTopMargin($this->marge_haute);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+ // We suppose that a too long description is moved completely on next page
+ if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
+ }
+
+ $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
+
+ // VAT Rate
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $pdf->SetXY($this->posxtva, $curY);
+ $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
+ }
+
+ // Unit price before discount
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $pdf->SetXY($this->posxup, $curY);
+ $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0);
+
+ // Quantity
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $pdf->SetXY($this->posxqty, $curY);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars
+
+ // Discount on line
+ if ($object->lines[$i]->remise_percent)
+ {
+ $pdf->SetXY($this->posxdiscount-2, $curY);
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
+ }
+
+ // Total HT line
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $pdf->SetXY($this->postotalht, $curY);
+ $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
+
+ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
+ $tvaligne=$object->lines[$i]->total_tva;
+
+ $localtax1ligne=$object->lines[$i]->total_localtax1;
+ $localtax2ligne=$object->lines[$i]->total_localtax2;
+ $localtax1_rate=$object->lines[$i]->localtax1_tx;
+ $localtax2_rate=$object->lines[$i]->localtax2_tx;
+ $localtax1_type=$object->lines[$i]->localtax1_type;
+ $localtax2_type=$object->lines[$i]->localtax2_type;
+
+ if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+
+ $vatrate=(string) $object->lines[$i]->tva_tx;
+
+ // TODO : store local taxes types into object lines and remove this
+ $localtax1_array=getTypeOfLocalTaxFromRate($vatrate,1,$mysoc);
+ $localtax2_array=getTypeOfLocalTaxFromRate($vatrate,2,$mysoc);
+ if (empty($localtax1_type))
+ $localtax1_type = $localtax1_array[0];
+ if (empty($localtax2_type))
+ $localtax2_type = $localtax2_array[0];
+ //end TODO
+
+ // retrieve global local tax
+ if ($localtax1_type == '7')
+ $localtax1_rate = $localtax1_array[1];
+ if ($localtax2_type == '7')
+ $localtax2_rate = $localtax2_array[1];
+
+ if ($localtax1ligne != 0 || $localtax1_type == '7')
+ $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ if ($localtax2ligne != 0 || $localtax2_type == '7')
+ $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
+ if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
+ $this->tva[$vatrate] += $tvaligne;
+
+ // Add line
+ if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
+ {
+ $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210)));
+ //$pdf->SetDrawColor(190,190,200);
+ $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->SetLineStyle(array('dash'=>0));
+ }
+
+ $nexY+=2; // Passe espace entre les lignes
+
+ // Detect if some page were added automatically and output _tableau for past pages
+ while ($pagenb < $pageposafter)
+ {
+ $pdf->setPage($pagenb);
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+ }
+ $this->_pagefoot($pdf,$object,$outputlangs,1);
+ $pagenb++;
+ $pdf->setPage($pagenb);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
+ }
+ if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ {
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
+ }
+ $this->_pagefoot($pdf,$object,$outputlangs,1);
+ // New page
+ $pdf->AddPage();
+ if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pagenb++;
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
+ }
+ }
+
+ // Show square
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
+ $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
+ $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+
+ // Affiche zone infos
+ $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+
+ // Affiche zone totaux
+ $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+
+ // Affiche zone versements
+ if ($deja_regle)
+ {
+ $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pied de page
+ $this->_pagefoot($pdf,$object,$outputlangs);
+ $pdf->AliasNbPages();
+
+ $pdf->Close();
+
+ $pdf->Output($file,'F');
+
+ // Add pdfgeneration hook
+ if (! is_object($hookmanager))
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+ $hookmanager=new HookManager($this->db);
+ }
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ return 1; // Pas d'erreur
+ }
+ else
+ {
+ $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
+ return 0;
+ }
+ }
+ else
+ {
+ $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
+ return 0;
+ }
+ $this->error=$langs->trans("ErrorUnknown");
+ return 0; // Erreur par defaut
+ }
+
+ /**
+ * Show payments table
+ *
+ * @param PDF &$pdf Object PDF
+ * @param Object $object Object order
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
+ */
+ function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
+ {
+
+ }
+
+
+ /**
+ * Show miscellaneous information (payment mode, payment term, ...)
+ *
+ * @param PDF &$pdf Object PDF
+ * @param Object $object Object to show
+ * @param int $posy Y
+ * @param Translate $outputlangs Langs object
+ * @return void
+ */
+ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
+ {
+ global $conf;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $pdf->SetFont('','', $default_font_size - 1);
+
+ // If France, show VAT mention if not applicable
+ if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
+ {
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
+
+ $posy=$pdf->GetY()+4;
+ }
+
+ $posxval=52;
+
+ // Show payments conditions
+ if ($object->cond_reglement_code || $object->cond_reglement)
+ {
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentConditions").':';
+ $pdf->MultiCell(80, 4, $titre, 0, 'L');
+
+ $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
+ $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
+
+ $posy=$pdf->GetY()+3;
+ }
+
+ // Check a payment mode is defined
+ /* Not used with orders
+ if (empty($object->mode_reglement_code)
+ && ! $conf->global->FACTURE_CHQ_NUMBER
+ && ! $conf->global->FACTURE_RIB_NUMBER)
+ {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetTextColor(200,0,0);
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
+ $pdf->SetTextColor(0,0,0);
+
+ $posy=$pdf->GetY()+1;
+ }
+ */
+
+ // Show payment mode
+ if ($object->mode_reglement_code
+ && $object->mode_reglement_code != 'CHQ'
+ && $object->mode_reglement_code != 'VIR')
+ {
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
+
+ $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
+
+ $posy=$pdf->GetY()+2;
+ }
+
+ // Show payment mode CHQ
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
+ {
+ // Si mode reglement non force ou si force a CHQ
+ if (! empty($conf->global->FACTURE_CHQ_NUMBER))
+ {
+ if ($conf->global->FACTURE_CHQ_NUMBER > 0)
+ {
+ $account = new Account($this->db);
+ $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
+
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetFont('','B', $default_font_size - 3);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
+ $posy=$pdf->GetY()+1;
+
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetFont('','', $default_font_size - 3);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
+ }
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1)
+ {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetFont('','B', $default_font_size - 3);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
+ $posy=$pdf->GetY()+1;
+
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetFont('','', $default_font_size - 3);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
+ $posy=$pdf->GetY()+2;
+ }
+ }
+ }
+ }
+
+ // If payment mode not forced or forced to VIR, show payment with BAN
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
+ {
+ if (! empty($conf->global->FACTURE_RIB_NUMBER))
+ {
+ $account = new Account($this->db);
+ $account->fetch($conf->global->FACTURE_RIB_NUMBER);
+
+ $curx=$this->marge_gauche;
+ $cury=$posy;
+
+ $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
+
+ $posy+=2;
+ }
+ }
+
+ return $posy;
+ }
+
+
+ /**
+ * Show total to pay
+ *
+ * @param PDF &$pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
+ * @param int $posy Position depart
+ * @param Translate $outputlangs Objet langs
+ * @return int Position pour suite
+ */
+ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
+ {
+ global $conf,$mysoc;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('','', $default_font_size - 1);
+
+ // Tableau total
+ $col1x = 120; $col2x = 170;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $col2x-=20;
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+
+ $useborder=0;
+ $index = 0;
+
+ // Total HT
+ $pdf->SetFillColor(255,255,255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
+
+ // Show VAT by rates and total
+ $pdf->SetFillColor(248,248,248);
+
+ $this->atleastoneratenotnull=0;
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
+ $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_ISNULL) && $tvaisnull)
+ {
+ // Nothing to do
+ }
+ else
+ {
+ //Local tax 1 before VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ {
+ foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '1':
+ case '3':
+ case '5':
+ case '7':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
+ {
+ if ($tvakey>0) // On affiche pas taux 0
+ {
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ }
+ }
+ //Local tax 2 before VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ {
+ foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '1':
+ case '3':
+ case '5':
+ case '7':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
+ {
+ if ($tvakey>0) // On affiche pas taux 0
+ {
+ //$this->atleastoneratenotnull++;
+
+
+
+ $index++;
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+
+ }
+ }
+ }
+ }
+ // VAT
+ foreach($this->tva as $tvakey => $tvaval)
+ {
+ if ($tvakey > 0) // On affiche pas taux 0
+ {
+ $this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat =$outputlangs->transnoentities("TotalVAT").' ';
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+
+ //Local tax 1 after VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ {
+ foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '2':
+ case '4':
+ case '6':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
+ {
+ if ($tvakey>0) // On affiche pas taux 0
+ {
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
+ if ($localtax_type == '7') { // amount on order
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
+ }
+ else
+ {
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ }
+ }
+ }
+ //Local tax 2 after VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ {
+ foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '2':
+ case '4':
+ case '6':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
+ {
+ if ($tvakey>0) // On affiche pas taux 0
+ {
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
+
+ if ($localtax_type == '7') { // amount on order
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
+ }
+ else
+ {
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ }
+ }
+ }
+
+ // Total TTC
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->SetFillColor(224,224,224);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
+ }
+ }
+
+ $pdf->SetTextColor(0,0,0);
+
+ $creditnoteamount=0;
+ $depositsamount=0;
+ //$creditnoteamount=$object->getSumCreditNotesUsed();
+ //$depositsamount=$object->getSumDepositsUsed();
+ //print "x".$creditnoteamount."-".$depositsamount;exit;
+ $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ if (! empty($object->paye)) $resteapayer=0;
+
+ if ($deja_regle > 0)
+ {
+ // Already paid + Deposits
+ $index++;
+
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
+
+ $index++;
+ $pdf->SetTextColor(0,0,60);
+ $pdf->SetFillColor(224,224,224);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
+
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetTextColor(0,0,0);
+ }
+
+ $index++;
+ return ($tab2_top + ($tab2_hl * $index));
+ }
+
+ /**
+ * Show table for lines
+ *
+ * @param PDF &$pdf Object PDF
+ * @param string $tab_top Top position of table
+ * @param string $tab_height Height of table (rectangle)
+ * @param int $nexY Y (not used)
+ * @param Translate $outputlangs Langs object
+ * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
+ * @param int $hidebottom Hide bottom bar of array
+ * @return void
+ */
+ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
+ {
+ global $conf;
+
+ // Force to disable hidetop and hidebottom
+ $hidebottom=0;
+ if ($hidetop) $hidetop=-1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ // Amount in (at tab_top - 1)
+ $pdf->SetTextColor(0,0,0);
+ $pdf->SetFont('','', $default_font_size - 2);
+
+ if (empty($hidetop))
+ {
+ $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency));
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+ }
+
+ $pdf->SetDrawColor(128,128,128);
+ $pdf->SetFont('','', $default_font_size - 1);
+
+ // Output Rect
+ $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
+
+ if (empty($hidetop))
+ {
+ $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
+
+ $pdf->SetXY($this->posxdesc-1, $tab_top+1);
+ $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
+ }
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
+ $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->posxtva-3, $tab_top+1);
+ $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
+ }
+ }
+
+ $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->posxup-1, $tab_top+1);
+ $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
+ }
+
+ $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->posxqty-1, $tab_top+1);
+ $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
+ }
+
+ $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ if ($this->atleastonediscount)
+ {
+ $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
+ $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
+ }
+ }
+
+ if ($this->atleastonediscount)
+ {
+ $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+ }
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
+ }
+ }
+
+ /**
+ * Show top header of page.
+ *
+ * @param PDF &$pdf Object PDF
+ * @param Object $object Object to show
+ * @param int $showaddress 0=no, 1=yes
+ * @param Translate $outputlangs Object lang for output
+ * @param object $hookmanager Hookmanager object
+ * @return void
+ */
+ function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
+ {
+ global $conf,$langs;
+
+ $outputlangs->load("main");
+ $outputlangs->load("bills");
+ $outputlangs->load("propal");
+ $outputlangs->load("companies");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
+
+ // Show Draft Watermark
+ if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
+ {
+ pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
+ }
+
+ $pdf->SetTextColor(0,0,60);
+ $pdf->SetFont('','B', $default_font_size + 3);
+
+ $posy=$this->marge_haute;
+ $posx=$this->page_largeur-$this->marge_droite-100;
+
+ $pdf->SetXY($this->marge_gauche,$posy);
+
+ // Logo
+ $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ if ($this->emetteur->logo)
+ {
+ if (is_readable($logo))
+ {
+ $height=pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
+ $pdf->SetTextColor(200,0,0);
+ $pdf->SetFont('','B', $default_font_size -2);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ }
+ else
+ {
+ $text=$this->emetteur->name;
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+ }
+
+ $pdf->SetFont('','B', $default_font_size + 3);
+ $pdf->SetXY($posx,$posy);
+ $pdf->SetTextColor(0,0,60);
+ $title=$outputlangs->transnoentities("Order");
+ $pdf->MultiCell(100, 3, $title, '', 'R');
+
+ $pdf->SetFont('','B',$default_font_size);
+
+ $posy+=5;
+ $pdf->SetXY($posx,$posy);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
+
+ $posy+=1;
+ $pdf->SetFont('','', $default_font_size - 1);
+
+ if ($object->ref_client)
+ {
+ $posy+=5;
+ $pdf->SetXY($posx,$posy);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
+
+ $posy+=4;
+ $pdf->SetXY($posx,$posy);
+ $pdf->SetTextColor(0,0,60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
+
+ $posy+=2;
+
+ // Show list of linked objects
+ $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
+
+ if ($showaddress)
+ {
+ // Sender properties
+ $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur);
+
+ // Show sender
+ $posy=42;
+ $posx=$this->marge_gauche;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
+ $hautcadre=40;
+
+ // Show sender frame
+ $pdf->SetTextColor(0,0,0);
+ $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetXY($posx,$posy-5);
+ $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
+ $pdf->SetXY($posx,$posy);
+ $pdf->SetFillColor(230,230,230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0,0,60);
+
+ // Show sender name
+ $pdf->SetXY($posx+2,$posy+3);
+ $pdf->SetFont('','B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+
+ // Show sender information
+ $pdf->SetXY($posx+2,$posy+8);
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
+
+
+
+ // If CUSTOMER contact defined on order, we use it
+ $usecontact=false;
+ $arrayidcontact=$object->getIdContact('external','CUSTOMER');
+ if (count($arrayidcontact) > 0)
+ {
+ $usecontact=true;
+ $result=$object->fetch_contact($arrayidcontact[0]);
+ }
+
+ // Recipient name
+ if (! empty($usecontact))
+ {
+ // On peut utiliser le nom de la societe du contact
+ if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
+ else $socname = $object->client->nom;
+ $carac_client_name=$outputlangs->convToOutputCharset($socname);
+ }
+ else
+ {
+ $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
+ }
+
+ $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target');
+
+ // Show recipient
+ $widthrecbox=100;
+ if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
+ $posy=42;
+ $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
+ if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+
+ // Show recipient frame
+ $pdf->SetTextColor(0,0,0);
+ $pdf->SetFont('','', $default_font_size - 2);
+ $pdf->SetXY($posx+2,$posy-5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
+
+ // Show recipient name
+ $pdf->SetXY($posx+2,$posy+3);
+ $pdf->SetFont('','B', $default_font_size);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
+
+ // Show recipient information
+ $pdf->SetFont('','', $default_font_size - 1);
+ $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
+ }
+ }
+
+ /**
+ * Show footer of page. Need this->emetteur object
+ *
+ * @param PDF &$pdf PDF
+ * @param Object $object Object to show
+ * @param Translate $outputlangs Object lang for output
+ * @param int $hidefreetext 1=Hide free text
+ * @return int Return height of bottom margin including footer text
+ */
+ function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
+ {
+ return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,0,$hidefreetext);
+ }
+
+}
+
+?>
diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
index a15f13a5cda..374474e1337 100644
--- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php
@@ -84,6 +84,7 @@ class pdf_expedition_merou extends ModelePdfExpedition
function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{
global $user,$conf,$langs,$mysoc;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
$object->fetch_thirdparty();
@@ -146,7 +147,6 @@ class pdf_expedition_merou extends ModelePdfExpedition
$nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format,'mm','l');
- $default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 0; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
index d84905a53a8..6cac5d287d9 100644
--- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php
@@ -87,6 +87,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{
global $user,$conf,$langs;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
$object->fetch_thirdparty();
@@ -132,8 +133,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition
$nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs);
- $heightforinfotot = 0; // Height reserved to output the info and total part
+ $heightforinfotot = 0; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 13ec3392364..c7d603f0622 100755
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -3,6 +3,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2008 Raphael Bertrand
* Copyright (C) 2010-2012 Juanjo Menent
+ * Copyright (C) 2012 Christophe Battarel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -138,7 +139,7 @@ class pdf_crabe extends ModelePDFFactures
*/
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{
- global $user,$langs,$conf;
+ global $user,$langs,$conf,$mysoc,$db;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -150,6 +151,8 @@ class pdf_crabe extends ModelePDFFactures
$outputlangs->load("bills");
$outputlangs->load("products");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
if ($conf->facture->dir_output)
{
$object->fetch_thirdparty();
@@ -184,7 +187,6 @@ class pdf_crabe extends ModelePDFFactures
$nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
@@ -196,7 +198,6 @@ class pdf_crabe extends ModelePDFFactures
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
-
// Set path to the background PDF File
if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
@@ -365,22 +366,40 @@ class pdf_crabe extends ModelePDFFactures
$tvaligne=$object->lines[$i]->total_tva;
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
+ $localtax1_rate=$object->lines[$i]->localtax1_tx;
+ $localtax2_rate=$object->lines[$i]->localtax2_tx;
+ $localtax1_type=$object->lines[$i]->localtax1_type;
+ $localtax2_type=$object->lines[$i]->localtax2_type;
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
$vatrate=(string) $object->lines[$i]->tva_tx;
- $localtax1rate=(string) $object->lines[$i]->localtax1_tx;
- $localtax2rate=(string) $object->lines[$i]->localtax2_tx;
+
+ // TODO : store local taxes types into object lines and remove this
+ $localtax1_array=getTypeOfLocalTaxFromRate($vatrate,1,$mysoc);
+ $localtax2_array=getTypeOfLocalTaxFromRate($vatrate,2,$mysoc);
+ if (empty($localtax1_type))
+ $localtax1_type = $localtax1_array[0];
+ if (empty($localtax2_type))
+ $localtax2_type = $localtax2_array[0];
+ //end TODO
+
+ // retrieve global local tax
+ if ($localtax1_type == '7')
+ $localtax1_rate = $localtax1_array[1];
+ if ($localtax2_type == '7')
+ $localtax2_rate = $localtax2_array[1];
+
+ if ($localtax1ligne != 0 || $localtax1_type == '7')
+ $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ if ($localtax2ligne != 0 || $localtax2_type == '7')
+ $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
- if (! isset($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]='';
- if (! isset($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]='';
$this->tva[$vatrate] += $tvaligne;
- $this->localtax1[$localtax1rate]+=$localtax1ligne;
- $this->localtax2[$localtax2rate]+=$localtax2ligne;
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -822,6 +841,84 @@ class pdf_crabe extends ModelePDFFactures
}
else
{
+ //Local tax 1 before VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ {
+ foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '1':
+ case '3':
+ case '5':
+ case '7':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
+ {
+ if ($tvakey>0) // On affiche pas taux 0
+ {
+ //$this->atleastoneratenotnull++;
+
+ $index++;
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
+ }
+ }
+ }
+ //Local tax 2 before VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ {
+ foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '1':
+ case '3':
+ case '5':
+ case '7':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
+ {
+ if ($tvakey>0) // On affiche pas taux 0
+ {
+ //$this->atleastoneratenotnull++;
+
+
+
+ $index++;
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
+
+ $tvacompl='';
+ if (preg_match('/\*/',$tvakey))
+ {
+ $tvakey=str_replace('*','',$tvakey);
+ $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
+ }
+ $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+
+ }
+ }
+ }
+ }
+ // VAT
foreach($this->tva as $tvakey => $tvaval)
{
if ($tvakey > 0) // On affiche pas taux 0
@@ -830,6 +927,7 @@ class pdf_crabe extends ModelePDFFactures
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+
$tvacompl='';
if (preg_match('/\*/',$tvakey))
{
@@ -839,52 +937,31 @@ class pdf_crabe extends ModelePDFFactures
$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
$totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
}
}
- if (! $this->atleastoneratenotnull) // If no vat at all
+ //Local tax 1 after VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
{
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_tva), 0, 'R', 1);
-
- // Total LocalTax1
- if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
- {
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax1), $useborder, 'R', 1);
- }
-
- // Total LocalTax2
- if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
- {
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_localtax2), $useborder, 'R', 1);
- }
- }
- else
- {
- if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
- {
- //Local tax 1
- foreach($this->localtax1 as $tvakey => $tvaval)
+ foreach( $this->localtax1 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '2':
+ case '4':
+ case '6':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey>0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$tvacompl='';
if (preg_match('/\*/',$tvakey))
@@ -892,27 +969,44 @@ class pdf_crabe extends ModelePDFFactures
$tvakey=str_replace('*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->country_code).' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' ';
+ if ($localtax_type == '7') { // amount on order
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1);
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
+ }
+ else
+ {
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
}
}
}
-
- if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
- {
- //Local tax 2
- foreach($this->localtax2 as $tvakey => $tvaval)
+ }
+ //Local tax 2 after VAT
+ if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ {
+ foreach( $this->localtax2 as $localtax_type => $localtax_rate ) {
+ switch ($localtax_type) {
+ case '2':
+ case '4':
+ case '6':
+ continue 2;
+ break;
+ }
+ foreach( $localtax_rate as $tvakey => $tvaval )
{
- if ($tvakey!=0) // On affiche pas taux 0
+ // retrieve global local tax
+ if ($tvakey>0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index);
$tvacompl='';
if (preg_match('/\*/',$tvakey))
@@ -920,12 +1014,21 @@ class pdf_crabe extends ModelePDFFactures
$tvakey=str_replace('*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' ';
- $totalvat.=vatrate($tvakey,1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' ';
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $tvaval), 0, 'R', 1);
+ if ($localtax_type == '7') { // amount on order
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvakey), 0, 'R', 1);
+ }
+ else
+ {
+ $totalvat.=vatrate($tvakey,1).$tvacompl;
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+
+ $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
+ }
}
}
}
@@ -936,11 +1039,10 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(224,224,224);
- $text=$outputlangs->transnoentities("TotalTTC");
- if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit");
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, 'L', 1);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->total_ttc), $useborder, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
}
}
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index 130f4409386..5d3246297bf 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -117,6 +117,8 @@ class pdf_soleil extends ModelePDFFicheinter
$outputlangs->load("companies");
$outputlangs->load("interventions");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
if ($conf->ficheinter->dir_output)
{
$object->fetch_thirdparty();
@@ -138,7 +140,6 @@ class pdf_soleil extends ModelePDFFicheinter
if (file_exists($dir))
{
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
index 3a1ed05dffa..a71f7be8aa7 100644
--- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
+++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
@@ -113,6 +113,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
function write_file($object,$outputlangs)
{
global $user,$langs,$conf;
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -149,7 +150,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (file_exists($dir))
{
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
index 888dadc62d6..6a38cd9f705 100644
--- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
@@ -108,6 +108,8 @@ class pdf_baleine extends ModelePDFProjects
{
$nblignes = count($object->lines);
+ $default_font_size = pdf_getPDFFontsize($outputlangs);
+
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output;
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
@@ -125,7 +127,6 @@ class pdf_baleine extends ModelePDFProjects
if (file_exists($dir))
{
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index fbe8534923d..93a415bd7c1 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -119,8 +119,6 @@ class pdf_azur extends ModelePDFPropales
$this->tva=array();
$this->localtax1=array();
$this->localtax2=array();
- $this->localtax1_type=array();
- $this->localtax2_type=array();
$this->atleastoneratenotnull=0;
$this->atleastonediscount=0;
}
@@ -139,7 +137,7 @@ class pdf_azur extends ModelePDFPropales
*/
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{
- global $user,$langs,$conf;
+ global $user,$langs,$conf,$mysoc,$db;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -152,6 +150,8 @@ class pdf_azur extends ModelePDFPropales
$outputlangs->load("propal");
$outputlangs->load("products");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
if ($conf->propal->dir_output)
{
$object->fetch_thirdparty();
@@ -186,7 +186,6 @@ class pdf_azur extends ModelePDFPropales
// Create pdf instance
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
@@ -364,31 +363,40 @@ class pdf_azur extends ModelePDFPropales
$tvaligne=$object->lines[$i]->total_tva;
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
+ $localtax1_rate=$object->lines[$i]->localtax1_tx;
+ $localtax2_rate=$object->lines[$i]->localtax2_tx;
+ $localtax1_type=$object->lines[$i]->localtax1_type;
+ $localtax2_type=$object->lines[$i]->localtax2_type;
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
$vatrate=(string) $object->lines[$i]->tva_tx;
+ // TODO : store local taxes types into object lines and remove this
+ $localtax1_array=getTypeOfLocalTaxFromRate($vatrate,1,$mysoc);
+ $localtax2_array=getTypeOfLocalTaxFromRate($vatrate,2,$mysoc);
+ if (empty($localtax1_type))
+ $localtax1_type = $localtax1_array[0];
+ if (empty($localtax2_type))
+ $localtax2_type = $localtax2_array[0];
+ //end TODO
+
+ // retrieve global local tax
+ if ($localtax1_type == '7')
+ $localtax1_rate = $localtax1_array[1];
+ if ($localtax2_type == '7')
+ $localtax2_rate = $localtax2_array[1];
+
+ if ($localtax1ligne != 0 || $localtax1_type == '7')
+ $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ if ($localtax2ligne != 0 || $localtax2_type == '7')
+ $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]='';
$this->tva[$vatrate] += $tvaligne;
- // Search local taxes
- $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
- $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$object->client->country_code."'";
- $sql .= " AND t.taux = ".$vatrate." AND t.active = 1";
-
- $resqlt=$this->db->query($sql);
- if ($resqlt)
- {
- $objt = $this->db->fetch_object($resqlt);
- $this->localtax1[$objt->localtax1_type][$objt->localtax1]+=$localtax1ligne;
- $this->localtax2[$objt->localtax2_type][$objt->localtax2]+=$localtax2ligne;
- }
-
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 0a723add648..d210a14a7f4 100755
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -146,6 +146,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$outputlangs->load("bills");
$outputlangs->load("products");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
if ($conf->fournisseur->dir_output.'/facture')
{
$object->fetch_thirdparty();
@@ -182,7 +184,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
index 69dcbaf2903..eb35a4b8b3b 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -156,6 +156,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$outputlangs->load("products");
$outputlangs->load("orders");
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
if ($conf->fournisseur->dir_output.'/commande')
{
$object->fetch_thirdparty();
@@ -194,7 +196,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index e3bf26df606..b3e2633fe9d 100755
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -127,7 +127,7 @@ class InterfaceActionsAuto
$langs->load("other");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
$object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
if ($object->prefix) $object->actionmsg.=" (".$object->prefix.")";
@@ -146,7 +146,7 @@ class InterfaceActionsAuto
$langs->load("contracts");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -160,7 +160,7 @@ class InterfaceActionsAuto
$langs->load("propal");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -174,7 +174,7 @@ class InterfaceActionsAuto
$langs->load("propal");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_EMAIL';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ProposalSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
@@ -192,7 +192,7 @@ class InterfaceActionsAuto
$langs->load("propal");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -206,7 +206,7 @@ class InterfaceActionsAuto
$langs->load("propal");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -220,7 +220,7 @@ class InterfaceActionsAuto
$langs->load("orders");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -234,7 +234,7 @@ class InterfaceActionsAuto
$langs->load("orders");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_EMAIL';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
@@ -253,7 +253,7 @@ class InterfaceActionsAuto
$langs->load("bills");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -268,7 +268,7 @@ class InterfaceActionsAuto
$langs->load("bills");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_EMAIL';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
@@ -288,7 +288,7 @@ class InterfaceActionsAuto
$langs->load("agenda");
// Values for this action can't be defined by caller.
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
$object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -303,7 +303,7 @@ class InterfaceActionsAuto
$langs->load("bills");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -318,7 +318,7 @@ class InterfaceActionsAuto
$langs->load("interventions");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InterventionValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -335,7 +335,7 @@ class InterfaceActionsAuto
$langs->load("interventions");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_EMAIL';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionSentByEMail",$object->ref);
$object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -351,7 +351,7 @@ class InterfaceActionsAuto
$langs->load("sendings");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_SHIP';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
@@ -369,7 +369,7 @@ class InterfaceActionsAuto
$langs->load("orders");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("OrderValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -385,7 +385,7 @@ class InterfaceActionsAuto
$langs->load("agenda");
$langs->load("orders");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_EMAIL';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierOrderSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
@@ -404,7 +404,7 @@ class InterfaceActionsAuto
$langs->load("bills");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -420,7 +420,7 @@ class InterfaceActionsAuto
$langs->load("agenda");
$langs->load("orders");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_EMAIL';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("SupplierInvoiceSentByEMail",$object->ref);
if (empty($object->actionmsg))
{
@@ -439,7 +439,7 @@ class InterfaceActionsAuto
$langs->load("bills");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoicePaidInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -454,7 +454,7 @@ class InterfaceActionsAuto
$langs->load("bills");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -471,7 +471,7 @@ class InterfaceActionsAuto
$langs->load("members");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("MemberValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -488,7 +488,7 @@ class InterfaceActionsAuto
$langs->load("members");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("MemberSubscriptionAddedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -511,7 +511,7 @@ class InterfaceActionsAuto
$langs->load("members");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("MemberResiliatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
@@ -528,7 +528,7 @@ class InterfaceActionsAuto
$langs->load("members");
$langs->load("agenda");
- $object->actiontypecode='AC_OTH_AUTO';
+ $object->actiontypecode='AC_OTH';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("MemberDeletedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Member").': '.$object->getFullName($langs);
diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php
index 721a0c94e52..2bd5b27537c 100644
--- a/htdocs/exports/class/export.class.php
+++ b/htdocs/exports/class/export.class.php
@@ -294,7 +294,7 @@ class Export
}
break;
case 'Boolean':
- $szFilterQuery=" ".$NameField."=".(is_numeric($ValueField) ? $ValueField : ($ValueField =='yes' ? 1: 0) );
+ $szFilterQuery=" ".$NameField."=".(is_numeric($ValueField) ? $ValueField : ($ValueField =='yes' ? 1: 0) );
break;
case 'Status':
case 'List':
diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php
index 6ffcc39e1c8..8f4ceefcba6 100644
--- a/htdocs/exports/export.php
+++ b/htdocs/exports/export.php
@@ -1122,7 +1122,7 @@ print ' ';
llxFooter();
-$db->close();
+$db->close();
/**
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 775116d8667..d8eaef777ad 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -889,7 +889,7 @@ class CommandeFournisseur extends CommonOrder
dol_syslog(get_class($this)."::commande sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
- $result = 1;
+ $result = 0;
$this->log($user, 3, $date, $comment);
}
else
@@ -954,67 +954,34 @@ class CommandeFournisseur extends CommonOrder
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."commande_fournisseur");
- if ($this->id) {
- $num=count($this->lines);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
+ $sql.= " SET ref='(PROV".$this->id.")'";
+ $sql.= " WHERE rowid=".$this->id;
+ dol_syslog(get_class($this)."::create sql=".$sql);
+ if ($this->db->query($sql))
+ {
+ // On logue creation pour historique
+ $this->log($user, 0, time());
- /*
- * Insertion du detail des produits dans la base
- */
- for ($i=0;$i<$num;$i++)
- {
- $result = $this->addline(
- $this->lines[$i]->desc,
- $this->lines[$i]->subprice,
- $this->lines[$i]->qty,
- $this->lines[$i]->tva_tx,
- $this->lines[$i]->localtax1_tx,
- $this->lines[$i]->localtax2_tx,
- $this->lines[$i]->fk_product,
- 0,
- $this->lines[$i]->ref_fourn,
- $this->lines[$i]->remise_percent,
- 'HT',
- 0,
- $this->lines[$i]->info_bits
- );
- if ($result < 0)
- {
- $this->error=$this->db->lasterror();
- dol_print_error($this->db);
- $this->db->rollback();
- return -1;
- }
- }
+ if (! $notrigger)
+ {
+ // Appel des triggers
+ include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf);
+ if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // Fin appel triggers
+ }
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
- $sql.= " SET ref='(PROV".$this->id.")'";
- $sql.= " WHERE rowid=".$this->id;
- dol_syslog(get_class($this)."::create sql=".$sql);
- if ($this->db->query($sql))
- {
- // On logue creation pour historique
- $this->log($user, 0, time());
-
- if (! $notrigger)
- {
- // Appel des triggers
- include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- $interface=new Interfaces($this->db);
- $result=$interface->run_triggers('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf);
- if ($result < 0) { $error++; $this->errors=$interface->errors; }
- // Fin appel triggers
- }
-
- $this->db->commit();
- return $this->id;
- }
- else
- {
- $this->error=$this->db->error();
- dol_syslog(get_class($this)."::create: Failed -2 - ".$this->error, LOG_ERR);
- $this->db->rollback();
- return -2;
- }
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ dol_syslog(get_class($this)."::create: Failed -2 - ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -2;
}
}
else
@@ -1026,69 +993,6 @@ class CommandeFournisseur extends CommonOrder
}
}
- /**
- * Load an object from its id and create a new one in database
- *
- * @param HookManager $hookmanager Hook manager instance
- * @return int New id of clone
- */
- function createFromClone($hookmanager=false)
- {
- global $conf,$user,$langs;
-
- $error=0;
-
- $this->db->begin();
-
- // Load source object
- $objFrom = dol_clone($this);
-
- $this->id=0;
- $this->statut=0;
-
- // Clear fields
- $this->user_author_id = $user->id;
- $this->user_valid = '';
- $this->date_creation = '';
- $this->date_validation = '';
- $this->ref_supplier = '';
-
- // Create clone
- $result=$this->create($user);
- if ($result < 0) $error++;
-
- if (! $error)
- {
- // Hook of thirdparty module
- if (is_object($hookmanager))
- {
- $parameters=array('objFrom'=>$objFrom);
- $action='';
- $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
- }
-
- // Appel des triggers
- include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- $interface=new Interfaces($this->db);
- $result=$interface->run_triggers('ORDER_SUPPLIER_CLONE',$this,$user,$langs,$conf);
- if ($result < 0) { $error++; $this->errors=$interface->errors; }
- // Fin appel triggers
- }
-
- // End
- if (! $error)
- {
- $this->db->commit();
- return $this->id;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
-
/**
* Add order line
*
@@ -1140,6 +1044,7 @@ class CommandeFournisseur extends CommonOrder
}
$desc=trim($desc);
+
// Check parameters
if ($qty < 1 && ! $fk_product)
{
@@ -1148,6 +1053,7 @@ class CommandeFournisseur extends CommonOrder
}
if ($type < 0) return -1;
+
if ($this->statut == 0)
{
$this->db->begin();
@@ -1170,7 +1076,7 @@ class CommandeFournisseur extends CommonOrder
$this->error="No price found for this quantity. Quantity may be too low ?";
$this->db->rollback();
dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG);
- return -1; // FIXME this return create an error in jenkins
+ return -1;
}
if ($result < -1)
{
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index e7e4c1d6161..e9e11a5d557 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -73,31 +73,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db);
$hookmanager->initHooks(array('ordersuppliercard'));
+$mesg='';
+$errors=array();
+
$object = new CommandeFournisseur($db);
-// Load object
-if ($id > 0 || ! empty($ref))
-{
- $ret = $object->fetch($id, $ref);
- if ($ret < 0) dol_print_error($db,$object->error);
- $ret = $object->fetch_thirdparty();
- if ($ret < 0) dol_print_error($db,$object->error);
-}
-else if (! empty($socid))
-{
- $fourn = new Fournisseur($db);
- $ret=$fourn->fetch($socid);
- if ($ret < 0) dol_print_error($db,$object->error);
- $object->socid = $fourn->id;
- $ret = $object->fetch_thirdparty();
- if ($ret < 0) dol_print_error($db,$object->error);
-}
/*
* Actions
*/
if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha'));
if ($result < 0) dol_print_error($db, $object->error);
}
@@ -105,12 +92,14 @@ if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
// conditions de reglement
if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
}
// mode de reglement
else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
}
@@ -119,38 +108,44 @@ if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->cree
{
$datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
+ $object->fetch($id);
$result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0)
{
- setEventMessage($object->error, 'errors');
+ $mesg=''.$object->error.'
';
}
}
// Set project
else if ($action == 'classin' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$object->setProject($projectid);
}
else if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']);
}
else if ($action == 'setnote_public' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'setnote' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
if ($result < 0) dol_print_error($db,$object->error);
}
else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver)
{
+ $result = $object->fetch($id);
if (in_array($object->statut, array(1, 5, 6, 7, 9)))
{
if ($object->statut == 1) $newstatus=0; // Validated->Draft
@@ -178,43 +173,46 @@ else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver)
else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
{
$langs->load('errors');
- $error = 0;
+ $error = false;
- if (GETPOST('pu') < 0 && GETPOST('qty') < 0)
+ if ($_POST['pu'] < 0 && $_POST['qty'] < 0)
{
setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors');
- $error++;
+ $error = true;
}
- if (! GETPOST('idprodfournprice') && GETPOST('type') < 0)
+ if (empty($_POST['idprodfournprice']) && $_POST['type'] < 0)
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
- $error++;
+ $error = true;
}
- if (! GETPOST('idprodfournprice') && (! GETPOST('pu') || GETPOST('pu')=='')) // Unit price can be 0 but not ''
+ if (empty($_POST['idprodfournprice']) && (! isset($_POST['pu']) || $_POST['pu']=='')) // Unit price can be 0 but not ''
{
setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice'))), 'errors');
- $error++;
+ $error = true;
}
- if (! GETPOST('idprodfournprice') && ! GETPOST('np_desc') && ! GETPOST('dp_desc'))
+ if (empty($_POST['idprodfournprice']) && empty($_POST['np_desc']) && empty($_POST['dp_desc']))
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
- $error++;
+ $error = true;
}
- if (! GETPOST('idprodfournprice') && (! GETPOST('qty') || GETPOST('qty') == '')
- || GETPOST('idprodfournprice') && (! GETPOST('pqty') || GETPOST('pqty') == ''))
+ if (empty($_POST['idprodfournprice']) && (! isset($_POST['qty']) || $_POST['qty'] == '')
+ || ! empty($_POST['idprodfournprice']) && (! isset($_POST['pqty']) || $_POST['pqty'] == ''))
{
setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
- $error++;
+ $error = true;
}
- if (! $error && ((GETPOST('qty') || GETPOST('pqty')) && ((GETPOST('pu') && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprodfournprice'))))
+ if (! $error && (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])))
{
+ if ($object->fetch($id) < 0) dol_print_error($db,$object->error);
+ if ($object->fetch_thirdparty() < 0) dol_print_error($db,$object->error);
+
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
- if (GETPOST('idprodfournprice')) // >0 or -1
+ if ($_POST["idprodfournprice"]) // >0 or -1
{
- $qty = GETPOST('qty') ? GETPOST('qty') : GETPOST('pqty');
+ $qty = $_POST['qty'] ? $_POST['qty'] : $_POST['pqty'];
$productsupplier = new ProductFournisseur($db);
$idprod=$productsupplier->get_buyprice($_POST['idprodfournprice'], $qty); // Just to see if a price exists for the quantity. Not used to found vat
@@ -231,9 +229,9 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$desc.= $productsupplier->description && $_POST['np_desc'] ? "\n" : "";
$desc.= $_POST['np_desc'];
- $remise_percent = GETPOST('remise_percent') ? GETPOST('remise_percent') : GETPOST('p_remise_percent');
+ $remise_percent = $_POST["remise_percent"] ? $_POST["remise_percent"] : $_POST["p_remise_percent"];
- $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
+ $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, $_POST['idprodfournprice']);
$type = $productsupplier->type;
// Local Taxes
@@ -242,13 +240,13 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$result=$object->addline(
$desc,
- $pu, // FIXME $pu is not defined
+ $pu,
$qty,
$tva_tx,
$localtax1_tx,
$localtax2_tx,
$productsupplier->id,
- GETPOST('idprodfournprice'),
+ $_POST['idprodfournprice'],
$productsupplier->fourn_ref,
$remise_percent,
'HT',
@@ -258,7 +256,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
if ($idprod == -1)
{
// Quantity too low
- setEventMessage($langs->trans("ErrorQtyTooLowForThisSupplier"), 'errors');
+ $mesg=''.$langs->trans("ErrorQtyTooLowForThisSupplier").'
';
}
}
else
@@ -273,7 +271,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
if (! $_POST['dp_desc'])
{
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors');
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
';
}
else
{
@@ -308,7 +306,7 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$outputlangs->setDefaultLang($newlang);
}
- $ret=$object->fetch($object->id); // Reload to get new records
+ $ret=$object->fetch($id); // Reload to get new records
supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
}
unset($_POST['qty']);
@@ -340,6 +338,9 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer
if ($product->fetch($_POST["elrowid"]) < 0) dol_print_error($db);
}
+ if ($object->fetch($id) < 0) dol_print_error($db,$object->error);
+ if ($object->fetch_thirdparty() < 0) dol_print_error($db,$object->error);
+
$localtax1_tx=get_localtax($_POST['tva_tx'],1,$object->thirdparty);
$localtax2_tx=get_localtax($_POST['tva_tx'],2,$object->thirdparty);
@@ -360,14 +361,14 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer
if ($result >= 0)
{
$outputlangs = $langs;
- if (GETPOST('lang_id'))
+ if (! empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang(GETPOST('lang_id'));
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $ret=$object->fetch($object->id); // Reload to get new records
+ $ret=$object->fetch($id); // Reload to get new records
supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
}
}
@@ -380,56 +381,60 @@ else if ($action == 'updateligne' && $user->rights->fournisseur->commande->creer
else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$result = $object->deleteline(GETPOST('lineid'));
if ($result >= 0)
{
$outputlangs = $langs;
- if (GETPOST('lang_id'))
+ if (! empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang(GETPOST('lang_id'));
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $ret=$object->fetch($object->id); // Reload to get new records
+ $ret=$object->fetch($id); // Reload to get new records
supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
}
}
else
{
$error++;
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
if (! $error)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
}
else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->commande->valider)
{
+ $object->fetch($id);
+ $object->fetch_thirdparty();
+
$object->date_commande=dol_now();
$result = $object->valid($user);
if ($result >= 0)
{
$outputlangs = $langs;
- if (GETPOST('lang_id'))
+ if (! empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang(GETPOST('lang_id'));
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- $ret=$object->fetch($object->id); // Reload to get new records
+ $ret=$object->fetch($id); // Reload to get new records
supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
}
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
// If we have permission, and if we don't need to provide th idwarehouse, we go directly on approved step
@@ -443,13 +448,16 @@ else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fou
{
$idwarehouse=GETPOST('idwarehouse', 'int');
+ $object->fetch($id);
+ $object->fetch_thirdparty();
+
// Check parameters
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))
{
if (! $idwarehouse || $idwarehouse == -1)
{
$error++;
- setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors');
+ $errors[]=$langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse"));
$action='';
}
}
@@ -459,47 +467,51 @@ else if ($action == 'confirm_approve' && $confirm == 'yes' && $user->rights->fou
$result = $object->approve($user, $idwarehouse);
if ($result > 0)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
}
}
else if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver)
{
+ $object->fetch($id);
$result = $object->refuse($user);
if ($result > 0)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
}
else if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander)
{
+ $object->fetch($id);
$result = $object->commande($user, $_REQUEST["datecommande"], $_REQUEST["methode"], $_REQUEST['comment']);
if ($result > 0)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
}
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer)
{
+ $object->fetch($id);
+ $object->fetch_thirdparty();
$result=$object->delete($user);
if ($result > 0)
{
@@ -508,39 +520,14 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->four
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
}
-// Action clone object
-else if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer)
-{
- if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
- {
- setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors');
- }
- else
- {
- if ($object->id > 0)
- {
- $result=$object->createFromClone($hookmanager);
- if ($result > 0)
- {
- header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
- exit;
- }
- else
- {
- setEventMessage($object->error, 'errors');
- $action='';
- }
- }
- }
-}
-
// Receive
else if ($action == 'livraison' && $user->rights->fournisseur->commande->receptionner)
{
+ $object->fetch($id);
if ($_POST["type"])
{
@@ -549,12 +536,12 @@ else if ($action == 'livraison' && $user->rights->fournisseur->commande->recepti
$result = $object->Livraison($user, $date_liv, $_POST["type"], $_POST["comment"]);
if ($result > 0)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else if($result == -3)
{
- setEventMessage($langs->trans("NotAuthorized"), 'errors');
+ $mesg=''.$langs->trans("NotAuthorized").'
';
}
else
{
@@ -570,21 +557,23 @@ else if ($action == 'livraison' && $user->rights->fournisseur->commande->recepti
else if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander)
{
+ $object->fetch($id);
$result = $object->cancel($user);
if ($result > 0)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
}
// Line ordering
else if ($action == 'up' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$object->line_up($_GET['rowid']);
$outputlangs = $langs;
@@ -594,11 +583,12 @@ else if ($action == 'up' && $user->rights->fournisseur->commande->creer)
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_order_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
- header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid']));
+ header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#'.$_GET['rowid']));
exit;
}
else if ($action == 'down' && $user->rights->fournisseur->commande->creer)
{
+ $object->fetch($id);
$object->line_down($_GET['rowid']);
$outputlangs = $langs;
@@ -617,17 +607,19 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) /
// Build document
// Sauvegarde le dernier module choisi pour generer un document
+ $object->fetch($id);
+ $object->fetch_thirdparty();
- if (GETPOST('model'))
+ if ($_REQUEST['model'])
{
- $object->setDocModel($user, GETPOST('model'));
+ $object->setDocModel($user, $_REQUEST['model']);
}
$outputlangs = $langs;
- if (GETPOST('lang_id'))
+ if (! empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang(GETPOST('lang_id'));
+ $outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
$result=supplier_order_pdf_create($db, $object,$object->modelpdf,$outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
if ($result <= 0)
@@ -643,41 +635,52 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) /
}
// Delete file in doc form
-else if ($action == 'remove_file' && $object->id > 0 && $user->rights->fournisseur->commande->creer)
+else if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $langs->load("other");
- $upload_dir = $conf->fournisseur->commande->dir_output;
- $file = $upload_dir . '/' . GETPOST('file');
- $ret=dol_delete_file($file,0,0,0,$object);
- if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
- else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
+
+ if ($object->fetch($id))
+ {
+ $object->fetch_thirdparty();
+
+ $langs->load("other");
+ $upload_dir = $conf->fournisseur->commande->dir_output;
+ $file = $upload_dir . '/' . GETPOST('file');
+ $ret=dol_delete_file($file,0,0,0,$object);
+ if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
+ else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
+ }
}
/*
* Create an order
*/
-else if ($action == 'create' && ! empty($object->socid) && $user->rights->fournisseur->commande->creer)
+else if ($action == 'create' && $user->rights->fournisseur->commande->creer)
{
$error=0;
+ $fourn = new Fournisseur($db);
+ $result=$fourn->fetch($socid);
+
+ $object->socid = $fourn->id;
+
$db->begin();
- $id=$object->create($user);
- if (! $id > 0)
+ $orderid=$object->create($user);
+ if (! $orderid > 0)
{
$error++;
- setEventMessage($object->error, 'errors');
+ $mesg=$object->error;
}
if (! $error)
{
if ($comclientid != '')
{
- $object->updateFromCommandeClient($user, $id, $comclientid);
+ $object->updateFromCommandeClient($user, $orderid, $comclientid);
}
- $ret=$object->fetch($id); // Reload to get new records
+ $id=$orderid;
$db->commit();
}
@@ -725,7 +728,10 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
{
$langs->load('mails');
- if ($object->id > 0)
+ $result=$object->fetch($_POST['orderid']);
+ $result=$object->fetch_thirdparty();
+
+ if ($result > 0)
{
// $ref = dol_sanitizeFileName($object->ref);
// $file = $conf->fournisseur->commande->dir_output . '/' . $ref . '/' . $ref . '.pdf';
@@ -792,15 +798,14 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt);
if ($mailfile->error)
{
- setEventMessage($mailfile->error, 'errors');
+ $mesg=''.$mailfile->error.'
';
}
else
{
$result=$mailfile->sendfile();
if ($result)
{
- $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
- setEventMessage($mesg);
+ $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
$error=0;
@@ -834,17 +839,17 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
else
{
$langs->load("other");
+ $mesg='';
if ($mailfile->error)
{
- $mesg = $langs->trans('ErrorFailedToSendMail',$from,$sendto);
- $mesg.= ' '.$mailfile->error;
+ $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
+ $mesg.=' '.$mailfile->error;
}
else
{
- $mesg = 'No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
+ $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
}
-
- setEventMessage($mesg, 'errors');
+ $mesg.='
';
}
}
/* }
@@ -859,14 +864,14 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
else
{
$langs->load("errors");
- setEventMessage($langs->trans('ErrorCantReadFile',$file), 'errors');
+ $mesg=''.$langs->trans('ErrorCantReadFile',$file).'
';
dol_syslog('Failed to read file: '.$file);
}
}
else
{
$langs->load("other");
- setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")), 'errors');
+ $mesg=''.$langs->trans('ErrorFailedToReadEntity',$langs->trans("Invoice")).'
';
dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
}
}
@@ -875,10 +880,12 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fourniss
{
if ($action == 'addcontact')
{
- if ($object->id > 0)
+ $result = $object->fetch($id);
+
+ if ($result > 0 && $id > 0)
{
$contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'));
- $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
+ $result = $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
@@ -891,24 +898,32 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fourniss
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
- setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors');
+ $mesg = ''.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'
';
}
else
{
- setEventMessage($object->error, 'errors');
+ $mesg = ''.$object->error.'
';
}
}
}
// bascule du statut d'un contact
- else if ($action == 'swapstatut' && $object->id > 0)
+ else if ($action == 'swapstatut')
{
- $result=$object->swapContactStatus(GETPOST('ligne'));
+ if ($object->fetch($id))
+ {
+ $result=$object->swapContactStatus(GETPOST('ligne'));
+ }
+ else
+ {
+ dol_print_error($db);
+ }
}
// Efface un contact
- else if ($action == 'deletecontact' && $object->id > 0)
+ else if ($action == 'deletecontact')
{
+ $object->fetch($id);
$result = $object->delete_contact($_GET["lineid"]);
if ($result >= 0)
@@ -943,899 +958,901 @@ $productstatic = new Product($db);
$now=dol_now();
-if (! empty($object->id))
+if ($id > 0 || ! empty($ref))
{
- $author = new User($db);
- $author->fetch($object->user_author_id);
-
- $head = ordersupplier_prepare_head($object);
-
- $title=$langs->trans("SupplierOrder");
- dol_fiche_head($head, 'card', $title, 0, 'order');
-
- /*
- * Confirmation de la suppression de la commande
- */
- if ($action == 'delete')
- {
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 2);
- if ($ret == 'html') print ' ';
- }
-
- // Clone confirmation
- if ($action == 'clone')
- {
- // Create an array for form
- $formquestion=array(
- //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1)
- );
- // Paiement incomplet. On demande si motif = escompte ou autre
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneOrder'),$langs->trans('ConfirmCloneOrder',$object->ref),'confirm_clone',$formquestion,'yes',1);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Confirmation de la validation
- */
- if ($action == 'valid')
- {
- $object->date_commande=dol_now();
-
- // We check if number is temporary number
- if (preg_match('/^[\(]?PROV/i',$object->ref)) $newref = $object->getNextNumRef($object->thirdparty);
- else $newref = $object->ref;
-
- $text=$langs->trans('ConfirmValidateOrder',$newref);
- if (! empty($conf->notification->enabled))
- {
- require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php';
- $notify=new Notify($db);
- $text.=' ';
- $text.=$notify->confirmMessage(3,$object->socid);
- }
-
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_valid', '', 0, 1);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Confirmation de l'approbation
- */
- if ($action == 'approve')
- {
- $formquestion=array();
- if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))
- {
- $langs->load("stocks");
- require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
- $formproduct=new FormProduct($db);
- $formquestion=array(
- //'text' => $langs->trans("ConfirmClone"),
- //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
- //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
- array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse'),'idwarehouse','',1))
- );
- }
-
- $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder",$object->ref),"confirm_approve", $formquestion, 1, 1, 240);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Confirmation de la desapprobation
- */
- if ($action == 'refuse')
- {
- $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$object->ref),"confirm_refuse", '', 0, 1);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Confirmation de l'annulation
- */
- if ($action == 'cancel')
- {
- $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$object->ref),"confirm_cancel", '', 0, 1);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Confirmation de l'envoi de la commande
- */
- if ($action == 'commande')
- {
- $date_com = dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
- $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"),$langs->trans("ConfirmMakeOrder",dol_print_date($date_com,'day')),"confirm_commande",'',0,2);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Confirmation de la suppression d'une ligne produit
- */
- if ($action == 'delete_product_line')
- {
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteproductline','',0,2);
- if ($ret == 'html') print ' ';
- }
-
- /*
- * Commande
- */
- $nbrow=8;
- if (! empty($conf->projet->enabled)) $nbrow++;
-
- //Local taxes
- if ($mysoc->country_code=='ES')
- {
- if($mysoc->localtax1_assuj=="1") $nbrow++;
- if($mysoc->localtax2_assuj=="1") $nbrow++;
- }
-
- print '';
-
- $linkback = ''.$langs->trans("BackToList").' ';
-
- // Ref
- print ''.$langs->trans("Ref").' ';
- print '';
- print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
- print ' ';
- print ' ';
-
- // Ref supplier
- print '';
- print $form->editfieldkey("RefSupplier",'ref_supplier',$langs->trans($object->ref_supplier),$object,$user->rights->fournisseur->commande->creer);
- print ' ';
- print $form->editfieldval("RefSupplier",'ref_supplier',$langs->trans($object->ref_supplier),$object,$user->rights->fournisseur->commande->creer);
- print ' ';
-
- // Fournisseur
- print ''.$langs->trans("Supplier")." ";
- print ''.$object->thirdparty->getNomUrl(1,'supplier').' ';
- print ' ';
-
- // Statut
- print '';
- print ''.$langs->trans("Status").' ';
- print '';
- print $object->getLibStatut(4);
- print " ";
-
- // Date
- if ($object->methode_commande_id > 0)
- {
- print ''.$langs->trans("Date").' ';
- if ($object->date_commande)
- {
- print dol_print_date($object->date_commande,"dayhourtext")."\n";
- }
- print " ";
-
- if ($object->methode_commande)
- {
- print ''.$langs->trans("Method").' '.$object->getInputMethod().' ';
- }
- }
-
- // Author
- print ''.$langs->trans("AuthorRequest").' ';
- print ''.$author->getNomUrl(1).' ';
- print ' ';
-
- // Conditions de reglement par defaut
- $langs->load('bills');
- $form = new Form($db);
- print '';
- print '';
- print ' ';
- if ($action == 'editconditions')
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'cond_reglement_id');
- }
- else
- {
- $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id,'none');
- }
- print " ";
- print ' ';
-
- // Mode of payment
- $langs->load('bills');
- $form = new Form($db);
- print '';
- print '';
- print ' ';
- if ($action == 'editmode')
- {
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
- }
- else
- {
- $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
- }
- print ' ';
-
- // Delivery date planed
- print '';
- print '';
- print ' ';
- if ($action == 'editdate_livraison')
- {
- print '';
- }
- else
- {
- print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : ' ';
- }
- print ' ';
-
- // Project
- if (! empty($conf->projet->enabled))
- {
- $langs->load('projects');
- print '';
- print '';
- print ' ';
- //print "$object->id, $object->socid, $object->fk_project";
- if ($action == 'classify')
- {
- $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$object->socid:'-1', $object->fk_project, 'projectid');
- }
- else
- {
- $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none');
- }
- print ' ';
- print ' ';
- }
-
- // Other attributes
- $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
- $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
-
- // Ligne de 3 colonnes
- print ''.$langs->trans("AmountHT").' ';
- print ''.price($object->total_ht).' ';
- print ''.$langs->trans("Currency".$conf->currency).' ';
-
- print ''.$langs->trans("AmountVAT").' '.price($object->total_tva).' ';
- print ''.$langs->trans("Currency".$conf->currency).' ';
-
- // Amount Local Taxes
- if ($mysoc->country_code=='ES')
- {
- if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
- {
- print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).' ';
- print ''.price($object->total_localtax1).' ';
- print ''.$langs->trans("Currency".$conf->currency).' ';
- }
- if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
- {
- print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).' ';
- print ''.price($object->total_localtax2).' ';
- print ''.$langs->trans("Currency".$conf->currency).' ';
- }
- }
- print ''.$langs->trans("AmountTTC").' '.price($object->total_ttc).' ';
- print ''.$langs->trans("Currency".$conf->currency).' ';
-
- print "
";
-
- if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
- {
- $blocname = 'contacts';
- $title = $langs->trans('ContactsAddresses');
- include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
- }
-
- if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
- {
- $blocname = 'notes';
- $title = $langs->trans('Notes');
- include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
- }
-
- /*
- * Lines
- */
- print '';
-
- $num = count($object->lines);
- $i = 0; $total = 0;
-
- if ($num)
- {
- print '';
- print ''.$langs->trans('Label').' ';
- print ''.$langs->trans('VAT').' ';
- print ''.$langs->trans('PriceUHT').' ';
- print ''.$langs->trans('Qty').' ';
- print ''.$langs->trans('ReductionShort').' ';
- print ''.$langs->trans('TotalHTShort').' ';
- print ' ';
- print " \n";
- }
- $var=true;
- while ($i < $num)
- {
- $line = $object->lines[$i];
- $var=!$var;
-
- // Show product and description
- $type=(! empty($line->product_type)?$line->product_type:(! empty($line->fk_product_type)?$line->fk_product_type:0));
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- $date_start='';
- $date_end='';
- if (! empty($line->date_start))
- {
- $date_start=$line->date_start;
- $type=1;
- }
- if (! empty($line->date_end))
- {
- $date_end=$line->date_end;
- $type=1;
- }
-
- // Ligne en mode visu
- if ($action != 'editline' || $_GET['rowid'] != $line->id)
- {
- print '';
-
- // Show product and description
- print '';
- if ($line->fk_product > 0)
- {
- print ' '; // ancre pour retourner sur la ligne
-
- $product_static=new ProductFournisseur($db);
- $product_static->fetch($line->fk_product);
- $text=$product_static->getNomUrl(1,'supplier');
- $text.= ' - '.$product_static->libelle;
- $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
- print $form->textwithtooltip($text,$description,3,'','',$i);
-
- // Show range
- print_date_range($date_start,$date_end);
-
- // Add description in form
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) print ($line->description && $line->description!=$product_static->libelle)?' '.dol_htmlentitiesbr($line->description):'';
- }
-
- // Description - Editor wysiwyg
- if (! $line->fk_product)
- {
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
- print $text.' '.nl2br($line->description);
-
- // Show range
- print_date_range($date_start,$date_end);
- }
-
- print ' ';
-
- print ''.vatrate($line->tva_tx).'% ';
-
- print ''.price($line->subprice)." \n";
-
- print ''.$line->qty.' ';
-
- if ($line->remise_percent > 0)
- {
- print ''.dol_print_reduction($line->remise_percent,$langs)." \n";
- }
- else
- {
- print ' ';
- }
-
- print ''.price($line->total_ht).' ';
- if ($object->statut == 0 && $user->rights->fournisseur->commande->creer)
- {
- print 'id.'&action=editline&rowid='.$line->id.'#'.$line->id.'">';
- print img_edit();
- print ' ';
-
- $actiondelete='delete_product_line';
- print 'id.'&action='.$actiondelete.'&lineid='.$line->id.'">';
- print img_delete();
- print ' ';
- }
- else
- {
- print ' ';
- }
- print " ";
- }
-
- // Ligne en mode update
- if ($action == 'editline' && $user->rights->fournisseur->commande->creer && ($_GET["rowid"] == $line->id))
- {
- print "\n";
- print '\n";
- }
- $i++;
- }
-
- /*
- * Form to add new line
- */
- if ($object->statut == 0 && $user->rights->fournisseur->commande->creer && $action <> 'editline')
- {
- //WYSIWYG Editor
- require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-
- print '';
- print '';
- print ' '; // ancre
- print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").' ';
- print ''.$langs->trans('VAT').' ';
- print ''.$langs->trans('PriceUHT').' ';
- print ''.$langs->trans('Qty').' ';
- print ''.$langs->trans('ReductionShort').' ';
- print ' ';
- print ' ';
-
- // TODO Use the predefinedproductline_create.tpl.php file
-
- // Add free products/services form
- print '';
- print '';
+ // Ajout de produits/services predefinis
+ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
+ {
+ print '';
+ print '';
+ print $langs->trans("AddNewLine").' - ';
+ if (! empty($conf->service->enabled))
+ {
+ print $langs->trans('RecordedProductsAndServices');
+ }
+ else
+ {
+ print $langs->trans('RecordedProducts');
+ }
+ print ' ';
+ print ''.$langs->trans('Qty').' ';
+ print ''.$langs->trans('ReductionShort').' ';
+ print ' ';
+ print ' ';
- // Ajout de produits/services predefinis
- if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
- {
- print '';
- print '';
- print $langs->trans("AddNewLine").' - ';
- if (! empty($conf->service->enabled))
- {
- print $langs->trans('RecordedProductsAndServices');
- }
- else
- {
- print $langs->trans('RecordedProducts');
- }
- print ' ';
- print ''.$langs->trans('Qty').' ';
- print ''.$langs->trans('ReductionShort').' ';
- print ' ';
- print ' ';
+ print '';
- }
- }
- print '
';
- print '';
-
-
- if ($action != 'presend')
- {
- /**
- * Boutons actions
- */
- if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete')
- {
- print '';
-
- // Validate
- if ($object->statut == 0 && $num > 0)
- {
- if ($user->rights->fournisseur->commande->valider)
+ if (is_object($hookmanager))
{
- print '
id.'&action=valid"';
- print '>'.$langs->trans('Validate').' ';
- }
- }
-
- // Modify
- if ($object->statut == 1)
- {
- if ($user->rights->fournisseur->commande->commander)
- {
- print '
id.'&action=reopen">'.$langs->trans("Modify").' ';
- }
- }
-
- // Approve
- if ($object->statut == 1)
- {
- if ($user->rights->fournisseur->commande->approuver)
- {
- print '
id.'&action=approve">'.$langs->trans("ApproveOrder").' ';
- print '
id.'&action=refuse">'.$langs->trans("RefuseOrder").' ';
- }
- else
- {
- print '
'.$langs->trans("ApproveOrder").' ';
- print '
'.$langs->trans("RefuseOrder").' ';
- }
- }
-
- // Send
- if (in_array($object->statut, array(2, 3, 4, 5)))
- {
- if ($user->rights->fournisseur->commande->commander)
- {
- print '
id.'&action=presend&mode=init">'.$langs->trans('SendByMail').' ';
- }
- }
-
- // Reopen
- if (in_array($object->statut, array(5, 6, 7, 9)))
- {
- if ($user->rights->fournisseur->commande->commander)
- {
- print '
id.'&action=reopen">'.$langs->trans("ReOpen").' ';
- }
- }
-
- // Create bill
- if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted
- {
- if ($user->rights->fournisseur->facture->creer)
- {
- print '
'.$langs->trans("CreateBill").' ';
+ $parameters=array('htmlname'=>'idprodfournprice');
+ $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action);
}
- //if ($user->rights->fournisseur->commande->creer && $object->statut > 2)
- //{
- // print '
id.'&action=classifybilled">'.$langs->trans("ClassifyBilled").' ';
- //}
- }
+ $nbrows=ROWS_2;
+ if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
+ $doleditor = new DolEditor('np_desc', GETPOST('np_desc'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, $nbrows, 70);
+ $doleditor->Create();
- // Cancel
- if ($object->statut == 2)
- {
- if ($user->rights->fournisseur->commande->commander)
- {
- print '
id.'&action=cancel">'.$langs->trans("CancelOrder").' ';
- }
- }
+ print '';
+ print '
';
+ print '
%';
+ print '
';
+ print '';
- // Clone
- if ($user->rights->fournisseur->commande->creer)
- {
- print '
'.$langs->trans("ToClone").' ';
- }
+ print '';
+ }
+ }
+ print '
';
+ print '';
- // Delete
- if ($user->rights->fournisseur->commande->supprimer)
- {
- print 'id.'&action=delete">'.$langs->trans("Delete").' ';
- }
- print "";
- }
+ if ($action != 'presend')
+ {
- print '';
- print ' '; // ancre
+ /**
+ * Boutons actions
+ */
+ if ($user->societe_id == 0 && $action != 'editline' && $action != 'delete')
+ {
+ print '';
- /*
- * Documents generes
- */
- $comfournref = dol_sanitizeFileName($object->ref);
- $file = $conf->fournisseur->dir_output . '/commande/' . $comfournref . '/' . $comfournref . '.pdf';
- $relativepath = $comfournref.'/'.$comfournref.'.pdf';
- $filedir = $conf->fournisseur->dir_output . '/commande/' . $comfournref;
- $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
- $genallowed=$user->rights->fournisseur->commande->creer;
- $delallowed=$user->rights->fournisseur->commande->supprimer;
+ // Validate
+ if ($object->statut == 0 && $num > 0)
+ {
+ if ($user->rights->fournisseur->commande->valider)
+ {
+ print '
id.'&action=valid"';
+ print '>'.$langs->trans('Validate').' ';
+ }
+ }
- print $formfile->showdocuments('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$object->thirdparty->default_lang);
- $somethingshown=$formfile->numoffiles;
+ // Modify
+ if ($object->statut == 1)
+ {
+ if ($user->rights->fournisseur->commande->commander)
+ {
+ print '
id.'&action=reopen">'.$langs->trans("Modify").' ';
+ }
+ }
- $object=$object;
+ // Approve
+ if ($object->statut == 1)
+ {
+ if ($user->rights->fournisseur->commande->approuver)
+ {
+ print '
id.'&action=approve">'.$langs->trans("ApproveOrder").' ';
+ print '
id.'&action=refuse">'.$langs->trans("RefuseOrder").' ';
+ }
+ else
+ {
+ print '
'.$langs->trans("ApproveOrder").' ';
+ print '
'.$langs->trans("RefuseOrder").' ';
+ }
+ }
- /*
- * Linked object block
- */
- $somethingshown=$object->showLinkedObjectBlock();
+ // Send
+ if (in_array($object->statut, array(2, 3, 4, 5)))
+ {
+ if ($user->rights->fournisseur->commande->commander)
+ {
+ print '
id.'&action=presend&mode=init">'.$langs->trans('SendByMail').' ';
+ }
+ }
- print '
';
+ // Reopen
+ if (in_array($object->statut, array(5, 6, 7, 9)))
+ {
+ if ($user->rights->fournisseur->commande->commander)
+ {
+ print 'id.'&action=reopen">'.$langs->trans("ReOpen").' ';
+ }
+ }
- if ($user->rights->fournisseur->commande->commander && $object->statut == 2)
- {
- /*
- * Commander (action=commande)
- */
- print ' ';
- print '';
- }
+ // Cancel
+ if ($object->statut == 2)
+ {
+ if ($user->rights->fournisseur->commande->commander)
+ {
+ print 'id.'&action=cancel">'.$langs->trans("CancelOrder").' ';
+ }
+ }
- if ($user->rights->fournisseur->commande->receptionner && ($object->statut == 3 || $object->statut == 4))
- {
- /*
- * Receptionner (action=livraison)
- */
- print ' ';
- print '\n";
- }
- // List of actions on element
- /* Hidden because" available into "Log" tab
- print ' ';
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
- $formactions=new FormActions($db);
- $somethingshown=$formactions->showactions($object,'order_supplier',$socid);
- */
+ print '';
+ print ' '; // ancre
- print '
';
- }
+ /*
+ * Documents generes
+ */
+ $comfournref = dol_sanitizeFileName($object->ref);
+ $file = $conf->fournisseur->dir_output . '/commande/' . $comfournref . '/' . $comfournref . '.pdf';
+ $relativepath = $comfournref.'/'.$comfournref.'.pdf';
+ $filedir = $conf->fournisseur->dir_output . '/commande/' . $comfournref;
+ $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
+ $genallowed=$user->rights->fournisseur->commande->creer;
+ $delallowed=$user->rights->fournisseur->commande->supprimer;
- /*
- * Action presend
- */
- if ($action == 'presend')
- {
- $ref = dol_sanitizeFileName($object->ref);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
- $file=$fileparams['fullname'];
+ print $formfile->showdocuments('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,0,0,'','','',$soc->default_lang);
+ $somethingshown=$formfile->numoffiles;
- // Build document if it not exists
- if (! $file || ! is_readable($file))
- {
- // Define output language
- $outputlangs = $langs;
- $newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
- if (! empty($newlang))
- {
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
- }
+ $object=$object;
- $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
- if ($result <= 0)
- {
- dol_print_error($db,$result);
- exit;
- }
- $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
- $file=$fileparams['fullname'];
- }
+ /*
+ * Linked object block
+ */
+ $somethingshown=$object->showLinkedObjectBlock();
- print ' ';
- print_titre($langs->trans('SendOrderByMail'));
+ print ' ';
- // Cree l'objet formulaire mail
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- $formmail = new FormMail($db);
- $formmail->fromtype = 'user';
- $formmail->fromid = $user->id;
- $formmail->fromname = $user->getFullName($langs);
- $formmail->frommail = $user->email;
- $formmail->withfrom=1;
- $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
- $formmail->withtosocid=$object->thirdparty->id;
- $formmail->withtocc=1;
- $formmail->withtoccsocid=0;
- $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false);
- $formmail->withtocccsocid=0;
- $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__');
- $formmail->withfile=2;
- $formmail->withbody=1;
- $formmail->withdeliveryreceipt=1;
- $formmail->withcancel=1;
- // Tableau des substitutions
- $formmail->substit['__ORDERREF__']=$object->ref;
- $formmail->substit['__SIGNATURE__']=$user->signature;
- $formmail->substit['__PERSONALIZED__']='';
- // Tableau des parametres complementaires
- $formmail->param['action']='send';
- $formmail->param['models']='order_supplier_send';
- $formmail->param['orderid']=$object->id;
- $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
+ if ($user->rights->fournisseur->commande->commander && $object->statut == 2)
+ {
+ /**
+ * Commander (action=commande)
+ */
+ print ' ';
+ print '';
+ }
- print ' ';
- }
+ if ($user->rights->fournisseur->commande->receptionner && ($object->statut == 3 || $object->statut == 4))
+ {
+ /**
+ * Receptionner (action=livraison)
+ */
+ print ' ';
+ print '
\n";
+ print "\n";
+ }
+
+ // List of actions on element
+ /* Hidden because" available into "Log" tab
+ print ' ';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+ $formactions=new FormActions($db);
+ $somethingshown=$formactions->showactions($object,'order_supplier',$socid);
+ */
+
+ print '';
+ }
+
+
+
+ /*
+ * Action presend
+ *
+ */
+ if ($action == 'presend')
+ {
+ $ref = dol_sanitizeFileName($object->ref);
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
+ $file=$fileparams['fullname'];
+
+ // Build document if it not exists
+ if (! $file || ! is_readable($file))
+ {
+ // Define output language
+ $outputlangs = $langs;
+ $newlang='';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $result=supplier_order_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
+ if ($result <= 0)
+ {
+ dol_print_error($db,$result);
+ exit;
+ }
+ $fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
+ $file=$fileparams['fullname'];
+ }
+
+ print ' ';
+ print_titre($langs->trans('SendOrderByMail'));
+
+ // Cree l'objet formulaire mail
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+ $formmail->fromtype = 'user';
+ $formmail->fromid = $user->id;
+ $formmail->fromname = $user->getFullName($langs);
+ $formmail->frommail = $user->email;
+ $formmail->withfrom=1;
+ $formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
+ $formmail->withtosocid=$soc->id;
+ $formmail->withtocc=1;
+ $formmail->withtoccsocid=0;
+ $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false);
+ $formmail->withtocccsocid=0;
+ $formmail->withtopic=$langs->trans('SendOrderRef','__ORDERREF__');
+ $formmail->withfile=2;
+ $formmail->withbody=1;
+ $formmail->withdeliveryreceipt=1;
+ $formmail->withcancel=1;
+ // Tableau des substitutions
+ $formmail->substit['__ORDERREF__']=$object->ref;
+ $formmail->substit['__SIGNATURE__']=$user->signature;
+ $formmail->substit['__PERSONALIZED__']='';
+ // Tableau des parametres complementaires
+ $formmail->param['action']='send';
+ $formmail->param['models']='order_supplier_send';
+ $formmail->param['orderid']=$object->id;
+ $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
+
+ // Init list of files
+ if (GETPOST("mode")=='init')
+ {
+ $formmail->clear_attached_files();
+ $formmail->add_attached_files($file,basename($file),dol_mimetype($file));
+ }
+
+ // Show form
+ $formmail->show_form();
+
+ print ' ';
+ }
+
+ print '';
+
+ }
+ else
+ {
+ // Commande non trouvee
+ dol_print_error($db);
+ }
}
// End of page
diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php
index f5cd59ba8d5..5bfbf4cff62 100644
--- a/htdocs/fourn/commande/liste.php
+++ b/htdocs/fourn/commande/liste.php
@@ -122,7 +122,7 @@ if ($resql)
print_barre_liste($title, $page, "liste.php", "", $sortfield, $sortorder, '', $num);
print '