Merge remote-tracking branch 'upstream/develop' into actioncomm_category

This commit is contained in:
Frédéric FRANCE
2019-11-16 09:21:57 +01:00
121 changed files with 7421 additions and 6942 deletions

View File

@@ -33,9 +33,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
*/
class box_goodcustomers extends ModeleBoxes
{
public $boxcode="goodcustomers";
public $boximg="object_company";
public $boxlabel="BoxGoodCustomers";
public $boxcode = "goodcustomers";
public $boximg = "object_company";
public $boxlabel = "BoxGoodCustomers";
public $depends = array("societe");
/**
@@ -62,10 +62,10 @@ class box_goodcustomers extends ModeleBoxes
$this->db = $db;
// disable box for such cases
if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled=0; // disabled by this option
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled=0; // not enabled by default. Very slow on large database
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database
$this->hidden = ! ($user->rights->societe->lire);
$this->hidden = !($user->rights->societe->lire);
}
/**
@@ -79,23 +79,23 @@ class box_goodcustomers extends ModeleBoxes
global $user, $langs, $conf;
$langs->load("boxes");
$this->max=$max;
$this->max = $max;
include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$thirdpartystatic=new Societe($this->db);
$thirdpartystatic = new Societe($this->db);
$this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max));
if ($user->rights->societe->lire)
{
$sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,";
$sql.= " count(*) as nbfact, sum(". $this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql.= ' WHERE s.entity IN ('.getEntity('societe').')';
$sql.= ' AND s.rowid = f.fk_soc';
$sql.= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status";
$sql.= $this->db->order("nbfact", "DESC");
$sql.= $this->db->plimit($max, 0);
$sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
$sql .= ' WHERE s.entity IN ('.getEntity('societe').')';
$sql .= ' AND s.rowid = f.fk_soc';
$sql .= " GROUP BY s.rowid, s.nom, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms, s.status";
$sql .= $this->db->order("nbfact", "DESC");
$sql .= $this->db->plimit($max, 0);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -107,7 +107,7 @@ class box_goodcustomers extends ModeleBoxes
while ($line < $num)
{
$objp = $this->db->fetch_object($result);
$datem=$this->db->jdate($objp->tms);
$datem = $this->db->jdate($objp->tms);
$thirdpartystatic->id = $objp->rowid;
$thirdpartystatic->name = $objp->name;
$thirdpartystatic->code_client = $objp->code_client;
@@ -131,7 +131,7 @@ class box_goodcustomers extends ModeleBoxes
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => $nbfact.( $nbimpaye != 0 ? ' ('.$nbimpaye.')':'')
'text' => $nbfact.($nbimpaye != 0 ? ' ('.$nbimpaye.')' : '')
);
$this->info_box_contents[$line][] = array(
@@ -142,7 +142,7 @@ class box_goodcustomers extends ModeleBoxes
$line++;
}
if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedCustomers"));
if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedCustomers"));
$this->db->free($result);
}

View File

@@ -31,8 +31,8 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
*/
class box_task extends ModeleBoxes
{
public $boxcode="projettask";
public $boximg="object_projecttask";
public $boxcode = "projettask";
public $boximg = "object_projecttask";
public $boxlabel;
public $depends = array("projet");
@@ -42,7 +42,7 @@ class box_task extends ModeleBoxes
public $db;
public $param;
public $enabled = 1; // enable because fixed ;-).
public $enabled = 1; // enable because fixed ;-).
public $info_box_head = array();
public $info_box_contents = array();
@@ -61,10 +61,10 @@ class box_task extends ModeleBoxes
// Load translation files required by the page
$langs->loadLangs(array('boxes', 'projects'));
$this->boxlabel="Tasks";
$this->boxlabel = "Tasks";
$this->db = $db;
$this->hidden = ! ($user->rights->projet->lire);
$this->hidden = !($user->rights->projet->lire);
}
/**
@@ -77,32 +77,32 @@ class box_task extends ModeleBoxes
{
global $conf, $user, $langs;
$this->max=$max;
$this->max = $max;
include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php";
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT."/core/lib/project.lib.php";
$projectstatic = new Project($this->db);
$taskstatic=new Task($this->db);
$form= new Form($this->db);
$cookie_name='boxfilter_task';
$boxcontent='';
$taskstatic = new Task($this->db);
$form = new Form($this->db);
$cookie_name = 'boxfilter_task';
$boxcontent = '';
$textHead = $langs->trans("CurentlyOpenedTasks");
$filterValue='all';
if(in_array(GETPOST($cookie_name), array('all','im_project_contact','im_task_contact'))){
$filterValue = 'all';
if (in_array(GETPOST($cookie_name), array('all', 'im_project_contact', 'im_task_contact'))) {
$filterValue = GETPOST($cookie_name);
}
elseif(!empty($_COOKIE[$cookie_name])){
elseif (!empty($_COOKIE[$cookie_name])) {
$filterValue = $_COOKIE[$cookie_name];
}
if($filterValue == 'im_task_contact'){
$textHead.= ' : '.$langs->trans("WhichIamLinkedTo");
if ($filterValue == 'im_task_contact') {
$textHead .= ' : '.$langs->trans("WhichIamLinkedTo");
}
elseif($filterValue == 'im_project_contact'){
$textHead.= ' : '.$langs->trans("WhichIamLinkedToProject");
elseif ($filterValue == 'im_project_contact') {
$textHead .= ' : '.$langs->trans("WhichIamLinkedToProject");
}
@@ -135,7 +135,7 @@ class box_task extends ModeleBoxes
});
</script>';
// set cookie by js
$boxcontent.='<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
$boxcontent .= '<script>date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "'.$cookie_name.'='.$filterValue.'; expires= " + date.toGMTString() + "; path=/ "; </script>';
$this->info_box_contents[0][] = array(
'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"',
'td' => 'class="nohover"',
@@ -144,43 +144,43 @@ class box_task extends ModeleBoxes
$sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress";
$sql.= ", p.rowid project_id, p.ref project_ref, p.title project_title";
$sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt";
$sql.= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)";
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task as pt";
$sql .= " JOIN ".MAIN_DB_PREFIX."projet as p ON (pt.fk_projet = p.rowid)";
if($filterValue === 'im_task_contact') {
$sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '" . $user->id . "' )";
$sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )";
if ($filterValue === 'im_task_contact') {
$sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = pt.rowid AND ec.fk_socpeople = '".$user->id."' )";
$sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project_task' AND tc.source = 'internal' )";
}
elseif($filterValue === 'im_project_contact') {
$sql .= " JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '" . $user->id . "' )";
$sql .= " JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )";
elseif ($filterValue === 'im_project_contact') {
$sql .= " JOIN ".MAIN_DB_PREFIX."element_contact as ec ON (ec.element_id = p.rowid AND ec.fk_socpeople = '".$user->id."' )";
$sql .= " JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON (ec.fk_c_type_contact = tc.rowid AND tc.element = 'project' AND tc.source = 'internal' )";
}
$sql.= " WHERE ";
$sql.= " pt.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
$sql.= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
$sql.= " AND p.usage_task = 1 ";
$sql .= " WHERE ";
$sql .= " pt.entity = ".$conf->entity;
$sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
$sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
$sql .= " AND p.usage_task = 1 ";
$sql.= " ORDER BY pt.datee ASC, pt.dateo ASC";
$sql.= $this->db->plimit($max, 0);
$sql .= " ORDER BY pt.datee ASC, pt.dateo ASC";
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
$i = 1;
if ($result) {
$num = $this->db->num_rows($result);
while ($objp = $this->db->fetch_object($result)) {
$taskstatic->id=$objp->rowid;
$taskstatic->ref=$objp->ref;
$taskstatic->label=$objp->label;
$taskstatic->id = $objp->rowid;
$taskstatic->ref = $objp->ref;
$taskstatic->label = $objp->label;
$taskstatic->progress = $objp->progress;
$taskstatic->fk_statut = $objp->fk_statut;
$taskstatic->date_end = $objp->datee;
$taskstatic->planned_workload= $objp->planned_workload;
$taskstatic->duration_effective= $objp->duration_effective;
$taskstatic->planned_workload = $objp->planned_workload;
$taskstatic->duration_effective = $objp->duration_effective;
$projectstatic->id = $objp->project_id;
$projectstatic->ref = $objp->project_ref;

View File

@@ -78,6 +78,7 @@ class CMailFile
//! Defined background directly in body tag
public $bodyCSS;
public $msgid;
public $headers;
public $message;
/**
@@ -263,7 +264,8 @@ class CMailFile
// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
// Action according to choosed sending method
// We set all data according to choosed sending method.
// We also set a value for ->msgid
if ($this->sendmode == 'mail')
{
// Use mail php function (default PHP method)
@@ -274,7 +276,7 @@ class CMailFile
$text_body = "";
$files_encoded = "";
// Define smtp_headers
// Define smtp_headers (this also set ->msgid)
$smtp_headers = $this->write_smtpheaders();
if (!empty($moreinheader)) $smtp_headers .= $moreinheader; // $moreinheader contains the \r\n
@@ -365,6 +367,9 @@ class CMailFile
$smtps->setErrorsTo($errors_to);
$smtps->setDeliveryReceipt($deliveryreceipt);
$host=dol_getprefix('email');
$this->msgid = time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host;
$this->smtps = $smtps;
}
elseif ($this->sendmode == 'swiftmailer')
@@ -386,7 +391,8 @@ class CMailFile
// Adding a trackid header to a message
$headers = $this->message->getHeaders();
$headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host);
$headerID = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host;
$this->msgid = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host;
$headerID = $this->msgid;
$msgid = $headers->get('Message-ID');
$msgid->setId($headerID);
$headers->addIdHeader('References', $headerID);
@@ -1038,13 +1044,15 @@ class CMailFile
if ($trackid)
{
// References is kept in response and Message-ID is returned into In-Reply-To:
$out .= 'Message-ID: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2; // Uppercase seems replaced by phpmail
$out .= 'References: <'.time().'.phpmail-dolibarr-'.$trackid.'@'.$host.">".$this->eol2;
$this->msgid = time().'.phpmail-dolibarr-'.$trackid.'@'.$host;
$out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; // Uppercase seems replaced by phpmail
$out .= 'References: <'.$this->msgid.">".$this->eol2;
$out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2;
}
else
{
$out .= 'Message-ID: <'.time().'.phpmail@'.$host.">".$this->eol2;
$this->msgid = time().'.phpmail@'.$host;
$out .= 'Message-ID: <'.$this->msgid.">".$this->eol2;
}
if (!empty($_SERVER['REMOTE_ADDR'])) $out .= "X-RemoteAddr: ".$_SERVER['REMOTE_ADDR'].$this->eol2;

View File

@@ -126,7 +126,7 @@ class Conf
$this->service = new stdClass();
$this->contrat = new stdClass();
$this->actions = new stdClass();
$this->agenda = new stdClass();
$this->agenda = new stdClass();
$this->commande = new stdClass();
$this->propal = new stdClass();
$this->facture = new stdClass();
@@ -354,11 +354,11 @@ class Conf
$this->propal->dir_output=$rootfordata."/propale";
$this->propal->dir_temp=$rootfordata."/propale/temp";
// For backward compatibility
$this->banque->multidir_output = array($this->entity => $rootfordata."/bank");
$this->banque->multidir_temp = array($this->entity => $rootfordata."/bank/temp");
$this->banque->dir_output=$rootfordata."/bank";
$this->banque->dir_temp=$rootfordata."/bank/temp";
// For bank storage
$this->bank->multidir_output = array($this->entity => $rootfordata."/bank");
$this->bank->multidir_temp = array($this->entity => $rootfordata."/bank/temp");
$this->bank->dir_output = $rootfordata."/bank";
$this->bank->dir_temp = $rootfordata."/bank/temp";
// For medias storage
$this->medias->multidir_output = array($this->entity => $rootfordata."/medias");

View File

@@ -174,7 +174,7 @@ class DolEditor
//$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" '.($this->readonly?' disabled':'').' rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
// TODO We do not put the disabled tag because on a read form, it change style with grey.
$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/', $this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
$out.= $this->content;
$out.= htmlspecialchars($this->content);
$out.= '</textarea>';
if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax) && ! empty($conf->fckeditor->enabled))

View File

@@ -82,8 +82,8 @@ class EmailSenderProfile extends CommonObject
'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1),
//'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
//'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1,),
'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>-1, 'enabled'=>1, 'position'=>400, 'notnull'=>-1, 'index'=>1,),
'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1),

View File

@@ -754,7 +754,7 @@ class FormOther
} ); });
</script>';
}
$out .= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat'.($morecss ? ' '.$morecss : '').'" type="text" value="'.$set_color.'" />';
$out .= '<input id="colorpicker'.$prefix.'" name="'.$prefix.'" size="6" maxlength="7" class="flat'.($morecss ? ' '.$morecss : '').'" type="text" value="'.dol_escape_htmltag($set_color).'" />';
}
else // In most cases, this is not used. We used instead function with no specific list of colors
{

View File

@@ -74,9 +74,9 @@ class Link extends CommonObject
*/
public function create($user = '')
{
global $langs,$conf;
global $langs, $conf;
$error=0;
$error = 0;
$langs->load("errors");
// Clean parameters
if (empty($this->label)) {
@@ -99,34 +99,34 @@ class Link extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."links (entity, datea, url, label, objecttype, objectid)";
$sql .= " VALUES ('".$conf->entity."', '".$this->db->idate($this->datea)."'";
$sql .= ", '" . $this->db->escape($this->url) . "'";
$sql .= ", '" . $this->db->escape($this->label) . "'";
$sql .= ", '" . $this->db->escape($this->objecttype) . "'";
$sql .= ", " . $this->objectid . ")";
$sql .= ", '".$this->db->escape($this->url)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->escape($this->objecttype)."'";
$sql .= ", ".$this->objectid.")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "links");
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."links");
if ($this->id > 0) {
// Call trigger
$result=$this->call_trigger('LINK_CREATE', $user);
$result = $this->call_trigger('LINK_CREATE', $user);
if ($result < 0) $error++;
// End call triggers
} else {
$error++;
}
if (! $error)
if (!$error)
{
dol_syslog(get_class($this)."::Create success id=" . $this->id);
dol_syslog(get_class($this)."::Create success id=".$this->id);
$this->db->commit();
return $this->id;
}
else
{
dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR);
dol_syslog(get_class($this)."::Create echec update ".$this->error, LOG_ERR);
$this->db->rollback();
return -3;
}
@@ -135,13 +135,13 @@ class Link extends CommonObject
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$langs->trans("ErrorCompanyNameAlreadyExists", $this->name);
$result=-1;
$this->error = $langs->trans("ErrorCompanyNameAlreadyExists", $this->name);
$result = -1;
}
else
{
$this->error=$this->db->lasterror();
$result=-2;
$this->error = $this->db->lasterror();
$result = -2;
}
$this->db->rollback();
return $result;
@@ -157,13 +157,13 @@ class Link extends CommonObject
*/
public function update($user = '', $call_trigger = 1)
{
global $langs,$conf;
global $langs, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("errors");
$error=0;
$error = 0;
dol_syslog(get_class($this)."::Update id = " . $this->id . " call_trigger = " . $call_trigger);
dol_syslog(get_class($this)."::Update id = ".$this->id." call_trigger = ".$call_trigger);
// Check parameters
if (empty($this->url))
@@ -180,30 +180,30 @@ class Link extends CommonObject
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "links SET ";
$sql .= "entity = '" . $conf->entity ."'";
$sql .= ", datea = '" . $this->db->idate(dol_now()) . "'";
$sql .= ", url = '" . $this->db->escape($this->url) . "'";
$sql .= ", label = '" . $this->db->escape($this->label) . "'";
$sql .= ", objecttype = '" . $this->db->escape($this->objecttype) . "'";
$sql .= ", objectid = " . $this->objectid;
$sql .= " WHERE rowid = " . $this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX."links SET ";
$sql .= "entity = '".$conf->entity."'";
$sql .= ", datea = '".$this->db->idate(dol_now())."'";
$sql .= ", url = '".$this->db->escape($this->url)."'";
$sql .= ", label = '".$this->db->escape($this->label)."'";
$sql .= ", objecttype = '".$this->db->escape($this->objecttype)."'";
$sql .= ", objectid = ".$this->objectid;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update sql = " .$sql);
dol_syslog(get_class($this)."::update sql = ".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
if ($call_trigger)
{
// Call trigger
$result=$this->call_trigger('LINK_MODIFY', $user);
$result = $this->call_trigger('LINK_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
if (!$error)
{
dol_syslog(get_class($this) . "::Update success");
dol_syslog(get_class($this)."::Update success");
$this->db->commit();
return 1;
} else {
@@ -218,12 +218,12 @@ class Link extends CommonObject
{
// Doublon
$this->error = $langs->trans("ErrorDuplicateField");
$result = -1;
$result = -1;
}
else
{
$this->error = $langs->trans("Error sql = " . $sql);
$result = -2;
$this->error = $langs->trans("Error sql = ".$sql);
$result = -2;
}
$this->db->rollback();
return $result;
@@ -244,14 +244,14 @@ class Link extends CommonObject
{
global $conf;
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links";
$sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid;
if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links";
$sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid;
if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity;
if ($sortfield) {
if (empty($sortorder)) {
$sortorder = "ASC";
}
$sql .= " ORDER BY " . $sortfield . " " . $sortorder;
$sql .= " ORDER BY ".$sortfield." ".$sortorder;
}
dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
@@ -259,7 +259,7 @@ class Link extends CommonObject
if ($resql)
{
$num = $this->db->num_rows($resql);
dol_syslog(get_class($this)."::fetchAll " . $num . "records", LOG_DEBUG);
dol_syslog(get_class($this)."::fetchAll ".$num."records", LOG_DEBUG);
if ($num > 0)
{
while ($obj = $this->db->fetch_object($resql))
@@ -295,9 +295,9 @@ class Link extends CommonObject
{
global $conf;
$sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links";
$sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid;
if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."links";
$sql .= " WHERE objecttype = '".$objecttype."' AND objectid = ".$objectid;
if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
@@ -322,15 +322,15 @@ class Link extends CommonObject
$rowid = $this->id;
}
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links";
$sql .= " WHERE rowid = " . $rowid;
if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity;
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM ".MAIN_DB_PREFIX."links";
$sql .= " WHERE rowid = ".$rowid;
if ($conf->entity != 0) $sql .= " AND entity = ".$conf->entity;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if($this->db->num_rows($resql) > 0)
if ($this->db->num_rows($resql) > 0)
{
$obj = $this->db->fetch_object($resql);
@@ -348,7 +348,7 @@ class Link extends CommonObject
return 0;
}
} else {
$this->error=$this->db->lasterror();
$this->error = $this->db->lasterror();
return -1;
}
}
@@ -367,7 +367,7 @@ class Link extends CommonObject
$this->db->begin();
// Call trigger
$result=$this->call_trigger('LINK_DELETE', $user);
$result = $this->call_trigger('LINK_DELETE', $user);
if ($result < 0)
{
$this->db->rollback();
@@ -376,17 +376,17 @@ class Link extends CommonObject
// End call triggers
// Remove link
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "links";
$sql.= " WHERE rowid = " . $this->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."links";
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (! $this->db->query($sql))
if (!$this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
}
if (! $error) {
if (!$error) {
$this->db->commit();
return 1;

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
*
* 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
@@ -45,17 +45,32 @@ class Menubase
public $errors = array();
/**
* @var int ID
*/
public $id;
* @var int ID
*/
public $id;
/**
* @var string Menu handler
*/
public $menu_handler;
/**
* @var string Module name if record is added by a module
*/
public $module;
/**
* @var string Menu top or left
*/
public $type;
/**
* @var string Name family/module for top menu (home, companies, ...)
*/
public $mainmenu;
/**
* @var int ID
* @var int 0 or Id of mother menu line, or -1 if we use fk_mainmenu and fk_leftmenu
*/
public $fk_menu;
@@ -70,23 +85,71 @@ class Menubase
public $fk_leftmenu;
/**
* @var int position
* @var int Sort order of entry
*/
public $position;
/**
* @var string Relative (or absolute) url to go
*/
public $url;
/**
* @var string Target of Url link
*/
public $target;
/**
* @var string Key for menu translation
* @deprecated
* @see title
*/
public $titre;
/**
* @var string Key for menu translation
*/
public $title;
/**
* @var string Lang file to load for translation
*/
public $langs;
/**
* @var string Not used
* @deprecated
*/
public $level;
public $leftmenu; //<! Not used
/**
* @var string Name family/module for left menu (setup, info, ...)
*/
public $leftmenu;
/**
* @var string Condition to show enabled or disabled
*/
public $perms;
/**
* @var string Condition to show or hide
*/
public $enabled;
/**
* @var int 0 if menu for all users, 1 for external only, 2 for internal only
*/
public $user;
/**
* @var int timestamp
*/
public $tms;
/**
* Constructor
* Constructor
*
* @param DoliDB $db Database handler
* @param string $menu_handler Menu handler
@@ -100,10 +163,10 @@ class Menubase
/**
* Create menu entry into database
* Create menu entry into database
*
* @param User $user User that create
* @return int <0 if KO, Id of record if OK
* @param User $user User that create
* @return int <0 if KO, Id of record if OK
*/
public function create($user = null)
{
@@ -125,7 +188,7 @@ class Menubase
$this->langs=trim($this->langs);
$this->perms=trim($this->perms);
$this->enabled=trim($this->enabled);
$this->user=trim($this->user);
$this->user = (int) $this->user;
if (empty($this->position)) $this->position=0;
if (! $this->level) $this->level=0;
@@ -246,7 +309,7 @@ class Menubase
*/
public function update($user = null, $notrigger = 0)
{
global $conf, $langs;
//global $conf, $langs;
// Clean parameters
$this->rowid=trim($this->rowid);
@@ -265,7 +328,7 @@ class Menubase
$this->langs=trim($this->langs);
$this->perms=trim($this->perms);
$this->enabled=trim($this->enabled);
$this->user=trim($this->user);
$this->user = (int) $this->user;
// Check parameters
// Put here code to add control on parameters values
@@ -311,7 +374,7 @@ class Menubase
*/
public function fetch($id, $user = null)
{
global $langs;
//global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
@@ -385,7 +448,7 @@ class Menubase
*/
public function delete($user)
{
global $conf, $langs;
//global $conf, $langs;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
$sql.= " WHERE rowid=".$this->id;

View File

@@ -1304,13 +1304,6 @@ class SMTPs
$_header .= 'Bcc: ' . $this->getBCC() . "\r\n";
*/
$host=$this->getHost();
$usetls = preg_match('@tls://@i', $host);
$host=preg_replace('@tcp://@i', '', $host); // Remove prefix
$host=preg_replace('@ssl://@i', '', $host); // Remove prefix
$host=preg_replace('@tls://@i', '', $host); // Remove prefix
$host=dol_getprefix('email');
//NOTE: Message-ID should probably contain the username of the user who sent the msg

View File

@@ -4275,7 +4275,9 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
}
}
print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist
if ($savlimit || $morehtmlright) {
print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist
}
print '</td>';
@@ -4302,7 +4304,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
global $conf, $langs;
print '<div class="pagination"><ul>';
if ((int) $limit >= 0 && empty($hideselectlimit))
if ((int) $limit > 0 && empty($hideselectlimit))
{
$pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
//$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
@@ -4317,7 +4319,6 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
$tmpkey = $conf->liste_limit.':'.$conf->liste_limit;
if (!in_array($tmpkey, $tmpchoice)) $tmpchoice[] = $tmpkey;
asort($tmpchoice, SORT_NUMERIC);
$found = false;
foreach ($tmpchoice as $val)
{
$selected = '';
@@ -4329,7 +4330,6 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
if ((int) $key == (int) $limit)
{
$selected = ' selected="selected"';
$found = true;
}
print '<option name="'.$key.'"'.$selected.'>'.dol_escape_htmltag($val).'</option>'."\n";
}
@@ -5212,16 +5212,18 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer,
if ($idprodfournprice > 0)
{
if (!class_exists('ProductFournisseur'))
if (!class_exists('ProductFournisseur')) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
}
$prodprice = new ProductFournisseur($db);
$prodprice->fetch_product_fournisseur_price($idprodfournprice);
return $prodprice->fourn_tva_npr;
}
elseif ($idprod > 0)
{
if (!class_exists('Product'))
if (!class_exists('Product')) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
}
$prod = new Product($db);
$prod->fetch($idprod);
return $prod->tva_npr;

View File

@@ -1258,9 +1258,15 @@ class pdf_einstein extends ModelePDFCommandes
// Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small;
}
else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
$height=pdf_getHeightForLogo($logo);

View File

@@ -1391,9 +1391,15 @@ class pdf_eratosthene extends ModelePDFCommandes
// Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small;
}
else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
$height=pdf_getHeightForLogo($logo);

View File

@@ -118,27 +118,27 @@ class pdf_merou extends ModelePdfExpedition
*/
public function __construct($db = 0)
{
global $conf,$langs,$mysoc;
global $conf, $langs, $mysoc;
$this->db = $db;
$this->name = "merou";
$this->description = $langs->trans("DocumentModelMerou");
$this->type = 'pdf';
$formatarray=pdf_getFormat();
$formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = round($formatarray['height']/2);
$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->page_hauteur = round($formatarray['height'] / 2);
$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; // Display logo
$this->option_logo = 1; // Display logo
// Get source company
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@@ -157,13 +157,13 @@ class pdf_merou extends ModelePdfExpedition
public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
global $user,$conf,$langs,$mysoc,$hookmanager;
global $user, $conf, $langs, $mysoc, $hookmanager;
$object->fetch_thirdparty();
if (! is_object($outputlangs)) $outputlangs=$langs;
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';
if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
@@ -180,31 +180,31 @@ class pdf_merou extends ModelePdfExpedition
//Create recipient
$idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
$this->destinataire = new Contact($this->db);
if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
//Create deliverer
$idcontact = $object->$origin->getIdContact('internal', 'LIVREUR');
$this->livreur = new User($this->db);
if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
// Definition of $dir and $file
if ($object->specimen)
{
$dir = $conf->expedition->dir_output."/sending";
$file = $dir . "/SPECIMEN.pdf";
$file = $dir."/SPECIMEN.pdf";
}
else
{
$expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output . "/sending/" . $expref;
$file = $dir . "/" . $expref . ".pdf";
$dir = $conf->expedition->dir_output."/sending/".$expref;
$file = $dir."/".$expref.".pdf";
}
if (! file_exists($dir))
if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -212,24 +212,24 @@ class pdf_merou extends ModelePdfExpedition
if (file_exists($dir))
{
// Add pdfgeneration hook
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$nblines = count($object->lines);
$pdf=pdf_getInstance($this->format, 'mm', 'l');
$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)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
$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)
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -239,14 +239,14 @@ class pdf_merou extends ModelePdfExpedition
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
if (!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;
$pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@@ -256,41 +256,41 @@ class pdf_merou extends ModelePdfExpedition
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment"));
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
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
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// New page
$pdf->AddPage();
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 52;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
// Display notes
if (! empty($object->note_public))
if (!empty($object->note_public))
{
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
$height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$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);
$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;
$tab_top = $nexY + 6;
}
else
{
$height_note=0;
$height_note = 0;
}
@@ -302,7 +302,7 @@ class pdf_merou extends ModelePdfExpedition
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
$num=count($object->lines);
$num = count($object->lines);
// Loop on each lines
for ($i = 0; $i < $num; $i++)
{
@@ -311,17 +311,17 @@ class pdf_merou extends ModelePdfExpedition
$pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$pageposbefore = $pdf->getPage();
// Description of product line
$libelleproduitservice = pdf_writelinedesc($pdf, $object, $i, $outputlangs, 90, 3, 50, $curY, 0, 1);
$nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();
$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.
$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) {
@@ -332,8 +332,8 @@ class pdf_merou extends ModelePdfExpedition
// Check boxes
$pdf->SetDrawColor(120, 120, 120);
$pdf->Rect(10+3, $curY, 3, 3);
$pdf->Rect(20+3, $curY, 3, 3);
$pdf->Rect(10 + 3, $curY, 3, 3);
$pdf->Rect(20 + 3, $curY, 3, 3);
//Inserting the product reference
$pdf->SetXY(30, $curY);
@@ -347,16 +347,16 @@ class pdf_merou extends ModelePdfExpedition
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
$nexY+=2; // Add space between lines
$nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -373,9 +373,9 @@ class pdf_merou extends ModelePdfExpedition
$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.
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -396,12 +396,12 @@ class pdf_merou extends ModelePdfExpedition
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;
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Pagefoot
@@ -413,22 +413,22 @@ class pdf_merou extends ModelePdfExpedition
$pdf->Output($file, 'F');
// Add pdfgeneration hook
if (! is_object($hookmanager))
if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
$hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$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
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
@@ -437,13 +437,13 @@ class pdf_merou extends ModelePdfExpedition
}
else
{
$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
$this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
$this->error=$outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
$this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
return 0;
}
}
@@ -531,20 +531,20 @@ class pdf_merou extends ModelePdfExpedition
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $conf, $langs,$hookmanager;
global $conf, $langs, $hookmanager;
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
//Affiche le filigrane brouillon - Print Draft Watermark
if($object->statut==0 && (! empty($conf->global->SENDING_DRAFT_WATERMARK)) )
if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK)))
{
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
}
$posy=$this->marge_haute;
$posx=$this->page_largeur-$this->marge_droite-100;
$posy = $this->marge_haute;
$posx = $this->page_largeur - $this->marge_droite - 100;
$Xoff = 90;
$Yoff = 0;
@@ -556,13 +556,13 @@ class pdf_merou extends ModelePdfExpedition
//*********************LOGO****************************
$pdf->SetXY(11, 7);
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->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, 10, 5, 0, $height); // width=0 (auto)
$height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
}
else
{
@@ -574,7 +574,7 @@ class pdf_merou extends ModelePdfExpedition
}
else
{
$text=$this->emetteur->name;
$text = $this->emetteur->name;
$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -583,9 +583,9 @@ class pdf_merou extends ModelePdfExpedition
$pdf->SetXY($Xoff, 7);
$pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->SetTextColor(0, 0, 0);
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("SendingSheet"), '', 'L'); // Sending sheet
//Num Expedition
$Yoff = $Yoff+7;
$Yoff = $Yoff + 7;
$Xoff = 142;
//$pdf->Rect($Xoff, $Yoff, 85, 8);
$pdf->SetXY($Xoff, $Yoff);
@@ -594,8 +594,8 @@ class pdf_merou extends ModelePdfExpedition
$pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefSending").': '.$outputlangs->convToOutputCharset($object->ref), '', 'R');
//$this->Code39($Xoff+43, $Yoff+1, $object->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
$origin = $object->origin;
$origin_id = $object->origin_id;
$origin = $object->origin;
$origin_id = $object->origin_id;
// Add list of linked elements
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager);
@@ -603,15 +603,15 @@ class pdf_merou extends ModelePdfExpedition
//$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true);
//Definition Location of the Company block
$Xoff = 110;
$blSocX=90;
$blSocY=24;
$blSocW=50;
$blSocX2=$blSocW+$blSocX;
$blSocX = 90;
$blSocY = 24;
$blSocW = 50;
$blSocX2 = $blSocW + $blSocX;
// Sender name
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetXY($blSocX, $blSocY+1);
$pdf->SetXY($blSocX, $blSocY + 1);
$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
$pdf->SetTextColor(0, 0, 0);
@@ -619,54 +619,54 @@ class pdf_merou extends ModelePdfExpedition
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->SetXY($blSocX, $blSocY+4);
$pdf->SetXY($blSocX, $blSocY + 4);
$pdf->MultiCell(80, 2, $carac_emetteur, 0, 'L');
if ($object->thirdparty->code_client)
{
$Yoff+=3;
$posy=$Yoff;
$Yoff += 3;
$posy = $Yoff;
$pdf->SetXY(100, $posy);
$pdf->SetTextColor(0, 0, 0);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
}
// Date delivery
$Yoff = $Yoff+7;
$pdf->SetXY($blSocX-80, $blSocY+17);
$Yoff = $Yoff + 7;
$pdf->SetXY($blSocX - 80, $blSocY + 17);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetTextColor(0, 0, 0);
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L');
$pdf->SetXY($blSocX-80, $blSocY+20);
$pdf->SetXY($blSocX - 80, $blSocY + 20);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetTextColor(0, 0, 0);
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L');
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
// Deliverer
$pdf->SetXY($blSocX-80, $blSocY+23);
$pdf->SetXY($blSocX - 80, $blSocY + 23);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->SetTextColor(0, 0, 0);
if (! empty($object->tracking_number))
if (!empty($object->tracking_number))
{
$object->getUrlTrackingStatus($object->tracking_number);
if (! empty($object->tracking_url))
if (!empty($object->tracking_url))
{
if ($object->shipping_method_id > 0)
{
// Get code using getLabelFromKey
$code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
$label='';
$label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
$label = '';
$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
//var_dump($object->tracking_url != $object->tracking_number);exit;
if ($object->tracking_url != $object->tracking_number)
{
$label.=" : ";
$label.=$object->tracking_url;
$label .= " : ";
$label .= $object->tracking_url;
}
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
@@ -681,20 +681,20 @@ class pdf_merou extends ModelePdfExpedition
// Shipping company (My Company)
$Yoff = $blSocY;
$blExpX=$Xoff-20;
$blW=52;
$blExpX = $Xoff - 20;
$blW = 52;
$Ydef = $Yoff;
$pdf->Rect($blExpX, $Yoff, $blW, 26);
$object->fetch_thirdparty();
// If SHIPPING contact defined on order, we use it
$usecontact=false;
$arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING');
$usecontact = false;
$arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
@@ -705,19 +705,19 @@ class pdf_merou extends ModelePdfExpedition
$thirdparty = $object->thirdparty;
}
$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact))?$object->contact:null), $usecontact, 'targetwithdetails', $object);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
$blDestX=$blExpX+55;
$blW=54;
$Yoff = $Ydef +1;
$blDestX = $blExpX + 55;
$blW = 54;
$Yoff = $Ydef + 1;
// Show Recipient frame
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetXY($blDestX, $Yoff-4);
$pdf->SetXY($blDestX, $Yoff - 4);
$pdf->MultiCell($blW, 3, $outputlangs->transnoentities("Recipient"), 0, 'L');
$pdf->Rect($blDestX, $Yoff-1, $blW, 26);
$pdf->Rect($blDestX, $Yoff - 1, $blW, 26);
// Show recipient name
$pdf->SetFont('', 'B', $default_font_size - 3);

View File

@@ -1616,9 +1616,15 @@ class pdf_crabe extends ModelePDFFactures
// Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{
$logo = $conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small;
}
else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
$height = pdf_getHeightForLogo($logo);

View File

@@ -1832,9 +1832,15 @@ class pdf_sponge extends ModelePDFFactures
// Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small;
}
else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
$height=pdf_getHeightForLogo($logo);

File diff suppressed because it is too large Load Diff

View File

@@ -1501,9 +1501,15 @@ class pdf_cyan extends ModelePDFPropales
// Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/thumbs/'.$this->emetteur->logo_small;
}
else {
$logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
}
if (is_readable($logo))
{
$height=pdf_getHeightForLogo($logo);

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@
* \brief File to manage password generation according to standard rule
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php';
/**
@@ -61,10 +61,10 @@ class modGeneratePassStandard extends ModeleGenPassword
$this->id = "standard";
$this->length = 8;
$this->db=$db;
$this->conf=$conf;
$this->langs=$langs;
$this->user=$user;
$this->db = $db;
$this->conf = $conf;
$this->langs = $langs;
$this->user = $user;
}
/**
@@ -108,7 +108,7 @@ class modGeneratePassStandard extends ModeleGenPassword
while ($i < $this->length)
{
// pick a random character from the possible ones
$char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1);
$char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1);
// we don't want this character if it's already in the password
if (!strstr($password, $char))

View File

@@ -218,7 +218,7 @@ elseif ($modulepart == 'bank')
{
$result = $object->fetch($id);
if ($result <= 0) dol_print_error($db, 'Failed to load object');
$dir=$conf->banque->dir_output; // By default
$dir=$conf->bank->dir_output; // By default
}
}
else {

View File

@@ -37,11 +37,11 @@ if ($user->socid > 0) $socid=$user->socid;
* View
*/
$socstatic=new Societe($db);
$socstatic = new Societe($db);
llxHeader("", $langs->trans("Tools"), "");
$text=$langs->trans("Tools");
$text = $langs->trans("Tools");
print load_fiche_titre($text, '', 'wrench');

View File

@@ -22,7 +22,7 @@
*/
// Protection to avoid direct call of template
if (empty($object) || ! is_object($object))
if (empty($object) || !is_object($object))
{
print "Error, template page can't be called as URL";
exit;
@@ -35,28 +35,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$module = $object->element;
// Special cases
if ($module == 'propal') { $permission=$user->rights->propale->creer; }
elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
elseif ($module == 'project') { $permission=$user->rights->projet->creer; }
elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; }
elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; }
elseif ($module == 'reception') { $permission=$user->rights->reception->creer; }
elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; }
elseif (! isset($permission) && isset($user->rights->$module->creer))
if ($module == 'propal') { $permission = $user->rights->propale->creer; }
elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; }
elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; }
elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; }
elseif ($module == 'project') { $permission = $user->rights->projet->creer; }
elseif ($module == 'action') { $permission = $user->rights->agenda->myactions->create; }
elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; }
elseif ($module == 'reception') { $permission = $user->rights->reception->creer; }
elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; }
elseif (!isset($permission) && isset($user->rights->$module->creer))
{
$permission=$user->rights->$module->creer;
$permission = $user->rights->$module->creer;
}
elseif (! isset($permission) && isset($user->rights->$module->write))
elseif (!isset($permission) && isset($user->rights->$module->write))
{
$permission=$user->rights->$module->write;
$permission = $user->rights->$module->write;
}
$formcompany= new FormCompany($db);
$companystatic=new Societe($db);
$contactstatic=new Contact($db);
$userstatic=new User($db);
$formcompany = new FormCompany($db);
$companystatic = new Societe($db);
$contactstatic = new Contact($db);
$userstatic = new User($db);
?>
@@ -90,11 +90,11 @@ if ($permission) {
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
<div class="nowrap tagtd"><?php echo img_object('', 'user').' '.$langs->trans("Users"); ?></div>
<div class="tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
<div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, '', 0, '', 'minwidth200imp'); ?></div>
<div class="tagtd maxwidthonsmartphone">
<?php
$tmpobject=$object;
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc;
$tmpobject = $object;
if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) $tmpobject = $objectsrc;
echo $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal');
?></div>
<div class="tagtd">&nbsp;</div>
@@ -116,7 +116,7 @@ if ($permission) {
<?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
<div class="tagtd nowrap noborderbottom"><?php echo img_object('', 'contact').' '.$langs->trans("ThirdPartyContacts"); ?></div>
<div class="tagtd nowrap maxwidthonsmartphone noborderbottom">
<?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
<?php $selectedCompany = isset($_GET["newcompany"]) ? $_GET["newcompany"] : $object->socid; ?>
<?php
// add company icon before select list
if ($selectedCompany)

View File

@@ -29,77 +29,77 @@ $isInvoice = in_array($object->element, array('facture', 'invoice', 'facture_fou
$isNewObject = empty($object->id) && empty($object->rowid);
// Relative and absolute discounts
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditRelativeDiscount") . '</a>';
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
$viewabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $thirdparty->id . '&backtopage=' . $backtopage . '">' . $langs->trans("ViewAvailableGlobalDiscounts") . '</a>';
$addrelativediscount = '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditRelativeDiscount").'</a>';
$addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("EditGlobalDiscounts").'</a>';
$viewabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$thirdparty->id.'&backtopage='.$backtopage.'">'.$langs->trans("ViewAvailableGlobalDiscounts").'</a>';
$fixedDiscount = $thirdparty->remise_percent;
if(! empty($discount_type)) {
if (!empty($discount_type)) {
$fixedDiscount = $thirdparty->remise_supplier_percent;
}
if ($fixedDiscount > 0)
{
$translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
$translationKey = (!empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount';
print $langs->trans($translationKey, $fixedDiscount).'.';
}
else
{
$translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
$translationKey = (!empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount';
print $langs->trans($translationKey).'.';
}
if($isNewObject) print ' ('.$addrelativediscount.')';
if ($isNewObject) print ' ('.$addrelativediscount.')';
// Is there is commercial discount or down payment available ?
if ($absolute_discount > 0) {
if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
$translationKey = ! empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)).'.';
if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) {
$translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount';
$text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.';
if ($isInvoice && ! $isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
if ($isInvoice && !$isNewObject && $object->statut > $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
$text = $form->textwithpicto($text, $langs->trans('AbsoluteDiscountUse'));
}
if ($isNewObject) {
$text.= ' ('.$addabsolutediscount.')';
$text .= ' ('.$addabsolutediscount.')';
}
print '<br>'.$text;
} else {
// Discount available of type fixed amount (not credit note)
$more = '(' . $addabsolutediscount . ')';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
$more = '('.$addabsolutediscount.')';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, GETPOST('discountid'), 'remise_id', $thirdparty->id, $absolute_discount, $filterabsolutediscount, $resteapayer, $more, 0, $discount_type);
}
}
// Is there credit notes availables ?
if ($absolute_creditnote > 0) {
// If validated, we show link "add credit note to payment"
if ($cannotApplyDiscount || ! $isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) {
$translationKey = ! empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency" . $conf->currency)) . '.';
if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) {
$translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote';
$text = $langs->trans($translationKey, price($absolute_creditnote), $langs->transnoentities("Currency".$conf->currency)).'.';
if ($isInvoice && ! $isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) {
if ($isInvoice && !$isNewObject && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_DEPOSIT) {
$text = $form->textwithpicto($text, $langs->trans('CreditNoteDepositUse'));
}
if ($absolute_discount <= 0 || $isNewObject) {
$text.= '('.$addabsolutediscount.')';
$text .= '('.$addabsolutediscount.')';
}
print '<br>'.$text;
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
// There is credit notes discounts available
$more = $isInvoice && ! $isNewObject ? ' (' . $viewabsolutediscount . ')' : '';
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
$more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : '';
$form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $thirdparty->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, $discount_type); // We allow credit note even if amount is higher
}
}
if($absolute_discount <= 0 && $absolute_creditnote <= 0) {
$translationKey = ! empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
if ($absolute_discount <= 0 && $absolute_creditnote <= 0) {
$translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount';
print '<br>'.$langs->trans($translationKey).'.';
if ($isInvoice && $object->statut == $objclassname::STATUS_DRAFT && $object->type != $objclassname::TYPE_CREDIT_NOTE && $object->type != $objclassname::TYPE_DEPOSIT) {
print ' (' . $addabsolutediscount . ')';
print ' ('.$addabsolutediscount.')';
}
}

View File

@@ -33,59 +33,59 @@
*/
// Protection to avoid direct call of template
if (empty($object) || ! is_object($object)) {
if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL";
exit;
}
$usemargins=0;
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande')))
$usemargins = 0;
if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')))
{
$usemargins=1;
$usemargins = 1;
}
if (! isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
if (!isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
if (! isset($dateSelector)) $dateSelector=1; // For backward compatibility
elseif (empty($dateSelector)) $dateSelector=0;
if (empty($forceall)) $forceall=0;
if (empty($senderissupplier)) $senderissupplier=0;
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
if (!isset($dateSelector)) $dateSelector = 1; // For backward compatibility
elseif (empty($dateSelector)) $dateSelector = 0;
if (empty($forceall)) $forceall = 0;
if (empty($senderissupplier)) $senderissupplier = 0;
if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0;
// Define colspan for the button 'Add'
$colspan = 3; // Columns: total ht + col edit + col delete
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required
if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
$colspan = 3; // Columns: total ht + col edit + col delete
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++; //Add column for Total (currency) if required
if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) $colspan++; // With this, there is a column move button
//print $object->element;
// Lines for extrafield
$objectline = null;
if (!empty($extrafields))
{
if ($this->table_element_line=='commandedet') {
if ($this->table_element_line == 'commandedet') {
$objectline = new OrderLine($this->db);
}
elseif ($this->table_element_line=='propaldet') {
elseif ($this->table_element_line == 'propaldet') {
$objectline = new PropaleLigne($this->db);
}
elseif ($this->table_element_line=='supplier_proposaldet') {
elseif ($this->table_element_line == 'supplier_proposaldet') {
$objectline = new SupplierProposalLine($this->db);
}
elseif ($this->table_element_line=='facturedet') {
elseif ($this->table_element_line == 'facturedet') {
$objectline = new FactureLigne($this->db);
}
elseif ($this->table_element_line=='contratdet') {
elseif ($this->table_element_line == 'contratdet') {
$objectline = new ContratLigne($this->db);
}
elseif ($this->table_element_line=='commande_fournisseurdet') {
elseif ($this->table_element_line == 'commande_fournisseurdet') {
$objectline = new CommandeFournisseurLigne($this->db);
}
elseif ($this->table_element_line=='facture_fourn_det') {
elseif ($this->table_element_line == 'facture_fourn_det') {
$objectline = new SupplierInvoiceLine($this->db);
}
elseif ($this->table_element_line=='facturedet_rec') {
elseif ($this->table_element_line == 'facturedet_rec') {
$objectline = new FactureLigneRec($this->db);
}
}