Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-02-13 15:42:54 +01:00
commit 306b8d190f
8 changed files with 528 additions and 528 deletions

View File

@ -1438,10 +1438,10 @@ class Propal extends CommonObject
$this->total_ttc = $obj->total; $this->total_ttc = $obj->total;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty
$this->fk_project = $obj->fk_project; $this->fk_project = $obj->fk_project;
$this->project = null; // Clear if another value was already set by fetch_projet $this->project = null; // Clear if another value was already set by fetch_projet
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->last_main_doc = $obj->last_main_doc; $this->last_main_doc = $obj->last_main_doc;

View File

@ -1741,10 +1741,10 @@ class Commande extends CommonOrder
$this->ref_int = $obj->ref_int; $this->ref_int = $obj->ref_int;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty
$this->fk_project = $obj->fk_project; $this->fk_project = $obj->fk_project;
$this->project = null; // Clear if another value was already set by fetch_projet $this->project = null; // Clear if another value was already set by fetch_projet
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;

View File

@ -250,7 +250,7 @@ class Facture extends CommonInvoice
/** /**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/ */
public $fields=array( public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
@ -1514,15 +1514,15 @@ class Facture extends CommonInvoice
$this->total_localtax2 = $obj->localtax2; $this->total_localtax2 = $obj->localtax2;
$this->total_ttc = $obj->total_ttc; $this->total_ttc = $obj->total_ttc;
$this->revenuestamp = $obj->revenuestamp; $this->revenuestamp = $obj->revenuestamp;
$this->paye = $obj->paye; $this->paye = $obj->paye;
$this->close_code = $obj->close_code; $this->close_code = $obj->close_code;
$this->close_note = $obj->close_note; $this->close_note = $obj->close_note;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty
$this->fk_project = $obj->fk_project; $this->fk_project = $obj->fk_project;
$this->project = null; // Clear if another value was already set by fetch_projet $this->project = null; // Clear if another value was already set by fetch_projet
$this->statut = $obj->fk_statut; $this->statut = $obj->fk_statut;
$this->date_lim_reglement = $this->db->jdate($obj->dlr); $this->date_lim_reglement = $this->db->jdate($obj->dlr);
@ -4104,7 +4104,7 @@ class Facture extends CommonInvoice
if ($generic_facture->hasDelay()) { if ($generic_facture->hasDelay()) {
$response->nbtodolate++; $response->nbtodolate++;
$response->url_late=DOL_URL_ROOT.'/compta/facture/list.php?search_option=late&mainmenu=billing&leftmenu=customers_bills'; $response->url_late = DOL_URL_ROOT.'/compta/facture/list.php?search_option=late&mainmenu=billing&leftmenu=customers_bills';
} }
} }

View File

@ -29,8 +29,8 @@
* \ingroup facture * \ingroup facture
* \brief File of class to manage payments of customers invoices * \brief File of class to manage payments of customers invoices
*/ */
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php'; require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
/** /**
@ -41,12 +41,12 @@ class Paiement extends CommonObject
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element='payment'; public $element = 'payment';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element='paiement'; public $table_element = 'paiement';
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@ -68,12 +68,12 @@ class Paiement extends CommonObject
*/ */
public $montant; public $montant;
public $amount; // Total amount of payment public $amount; // Total amount of payment
public $amounts=array(); // Array of amounts public $amounts = array(); // Array of amounts
public $multicurrency_amounts=array(); // Array of amounts public $multicurrency_amounts = array(); // Array of amounts
public $author; public $author;
public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement public $paiementid; // Type of payment. Id saved into fields fk_paiement on llx_paiement
public $paiementcode; // Code of payment. public $paiementcode; // Code of payment.
/** /**
* @var string type libelle * @var string type libelle
@ -136,7 +136,7 @@ class Paiement extends CommonObject
/** /**
* @var int payment id * @var int payment id
*/ */
public $fk_paiement; // Type of payment public $fk_paiement; // Type of payment
/** /**
@ -160,18 +160,18 @@ class Paiement extends CommonObject
public function fetch($id, $ref = '', $fk_bank = '') public function fetch($id, $ref = '', $fk_bank = '')
{ {
$sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,'; $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,';
$sql.= ' c.code as type_code, c.libelle as type_label,'; $sql .= ' c.code as type_code, c.libelle as type_label,';
$sql.= ' p.num_paiement as num_payment, p.note,'; $sql .= ' p.num_paiement as num_payment, p.note,';
$sql.= ' b.fk_account'; $sql .= ' b.fk_account';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql.= ' WHERE p.entity IN (' . getEntity('invoice').')'; $sql .= ' WHERE p.entity IN ('.getEntity('invoice').')';
if ($id > 0) if ($id > 0)
$sql.= ' AND p.rowid = '.$id; $sql .= ' AND p.rowid = '.$id;
elseif ($ref) elseif ($ref)
$sql.= " AND p.ref = '".$ref."'"; $sql .= " AND p.ref = '".$ref."'";
elseif ($fk_bank) elseif ($fk_bank)
$sql.= ' AND p.fk_bank = '.$fk_bank; $sql .= ' AND p.fk_bank = '.$fk_bank;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -180,15 +180,15 @@ class Paiement extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->ref?$obj->ref:$obj->rowid; $this->ref = $obj->ref ? $obj->ref : $obj->rowid;
$this->date = $this->db->jdate($obj->dp); $this->date = $this->db->jdate($obj->dp);
$this->datepaye = $this->db->jdate($obj->dp); $this->datepaye = $this->db->jdate($obj->dp);
$this->num_paiement = $obj->num_payment; // deprecated $this->num_paiement = $obj->num_payment; // deprecated
$this->num_payment = $obj->num_payment; $this->num_payment = $obj->num_payment;
$this->montant = $obj->amount; // deprecated $this->montant = $obj->amount; // deprecated
$this->amount = $obj->amount; $this->amount = $obj->amount;
$this->note = $obj->note; $this->note = $obj->note;
$this->type_label = $obj->type_label; $this->type_label = $obj->type_label;
$this->type_code = $obj->type_code; $this->type_code = $obj->type_code;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->ext_payment_id = $obj->ext_payment_id; $this->ext_payment_id = $obj->ext_payment_id;
@ -231,7 +231,7 @@ class Paiement extends CommonObject
$error = 0; $error = 0;
$way = $this->getWay(); $way = $this->getWay();
$now=dol_now(); $now = dol_now();
// Clean parameters // Clean parameters
$totalamount = 0; $totalamount = 0;
@ -258,7 +258,7 @@ class Paiement extends CommonObject
$newvalue = price2num($value, 'MT'); $newvalue = price2num($value, 'MT');
$amounts[$key] = $newvalue; $amounts[$key] = $newvalue;
$totalamount += $newvalue; $totalamount += $newvalue;
if (! empty($newvalue)) $atleastonepaymentnotnull++; if (!empty($newvalue)) $atleastonepaymentnotnull++;
} }
$totalamount = price2num($totalamount); $totalamount = price2num($totalamount);
@ -267,8 +267,8 @@ class Paiement extends CommonObject
// Check parameters // Check parameters
if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays if (empty($totalamount) && empty($atleastonepaymentnotnull)) // We accept negative amounts for withdraw reject but not empty arrays
{ {
$this->errors[]='TotalAmountEmpty'; $this->errors[] = 'TotalAmountEmpty';
$this->error='TotalAmountEmpty'; $this->error = 'TotalAmountEmpty';
return -1; return -1;
} }
@ -276,7 +276,7 @@ class Paiement extends CommonObject
$this->db->begin(); $this->db->begin();
$this->ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:''); $this->ref = $this->getNextNumRef(is_object($thirdparty) ? $thirdparty : '');
if ($way == 'dolibarr') if ($way == 'dolibarr')
{ {
@ -289,11 +289,11 @@ class Paiement extends CommonObject
$mtotal = $totalamount; $mtotal = $totalamount;
} }
$num_payment = ($this->num_payment?$this->num_payment:$this->num_paiement); $num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement);
$note = ($this->note_public?$this->note_public:$this->note); $note = ($this->note_public ? $this->note_public : $this->note);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)";
$sql.= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id?"'".$this->db->escape($this->ext_payment_id)."'":"null").", ".($this->ext_payment_site?"'".$this->db->escape($this->ext_payment_site)."'":"null").", ".$user->id.")"; $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
@ -308,23 +308,23 @@ class Paiement extends CommonObject
{ {
$amount = price2num($amount); $amount = price2num($amount);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)';
$sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')'; $sql .= ' VALUES ('.$facid.', '.$this->id.', \''.$amount.'\', \''.$this->multicurrency_amounts[$key].'\')';
dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG); dol_syslog(get_class($this).'::create Amount line '.$key.' insert paiement_facture', LOG_DEBUG);
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$invoice=new Facture($this->db); $invoice = new Facture($this->db);
$invoice->fetch($facid); $invoice->fetch($facid);
// If we want to closed payed invoices // If we want to closed payed invoices
if ($closepaidinvoices) if ($closepaidinvoices)
{ {
$paiement = $invoice->getSommePaiement(); $paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed(); $creditnotes = $invoice->getSumCreditNotesUsed();
$deposits=$invoice->getSumDepositsUsed(); $deposits = $invoice->getSumDepositsUsed();
$alreadypayed=price2num($paiement + $creditnotes + $deposits, 'MT'); $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
//var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit; //var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit;
@ -395,12 +395,12 @@ class Paiement extends CommonObject
} }
// Set invoice to paid // Set invoice to paid
if (! $error) if (!$error)
{ {
$result=$invoice->set_paid($user, '', ''); $result = $invoice->set_paid($user, '', '');
if ($result<0) if ($result < 0)
{ {
$this->error=$invoice->error; $this->error = $invoice->error;
$error++; $error++;
} }
} }
@ -412,13 +412,13 @@ class Paiement extends CommonObject
{ {
dol_syslog(get_class($this).'::create Regenerate the document after inserting payment for thirdparty default_lang='.(is_object($invoice->thirdparty) ? $invoice->thirdparty->default_lang : 'null'), LOG_DEBUG); dol_syslog(get_class($this).'::create Regenerate the document after inserting payment for thirdparty default_lang='.(is_object($invoice->thirdparty) ? $invoice->thirdparty->default_lang : 'null'), LOG_DEBUG);
$newlang=''; $newlang = '';
$outputlangs = $langs; $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$invoice->fetch_thirdparty(); $invoice->fetch_thirdparty();
$newlang = $invoice->thirdparty->default_lang; $newlang = $invoice->thirdparty->default_lang;
} }
if (! empty($newlang)) { if (!empty($newlang)) {
$outputlangs = new Translate("", $conf); $outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
@ -432,7 +432,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
$error++; $error++;
} }
} }
@ -442,25 +442,25 @@ class Paiement extends CommonObject
} }
} }
if (! $error) // All payments into $this->amounts were recorded without errors if (!$error) // All payments into $this->amounts were recorded without errors
{ {
// Appel des triggers // Appel des triggers
$result=$this->call_trigger('PAYMENT_CUSTOMER_CREATE', $user); $result = $this->call_trigger('PAYMENT_CUSTOMER_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// Fin appel triggers // Fin appel triggers
} }
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
$error++; $error++;
} }
if (! $error) if (!$error)
{ {
$this->amount=$total; $this->amount = $total;
$this->total=$total; // deprecated $this->total = $total; // deprecated
$this->multicurrency_amount=$mtotal; $this->multicurrency_amount = $mtotal;
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} }
@ -484,7 +484,7 @@ class Paiement extends CommonObject
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error=0; $error = 0;
$bank_line_id = $this->bank_line; $bank_line_id = $this->bank_line;
@ -492,12 +492,12 @@ class Paiement extends CommonObject
// Verifier si paiement porte pas sur une facture classee // Verifier si paiement porte pas sur une facture classee
// Si c'est le cas, on refuse la suppression // Si c'est le cas, on refuse la suppression
$billsarray=$this->getBillsArray('fk_statut > 1'); $billsarray = $this->getBillsArray('fk_statut > 1');
if (is_array($billsarray)) if (is_array($billsarray))
{ {
if (count($billsarray)) if (count($billsarray))
{ {
$this->error="ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible"; $this->error = "ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -513,32 +513,32 @@ class Paiement extends CommonObject
{ {
$accline = new AccountLine($this->db); $accline = new AccountLine($this->db);
$result=$accline->fetch($bank_line_id); $result = $accline->fetch($bank_line_id);
if ($result == 0) $accline->rowid=$bank_line_id; // If not found, we set artificially rowid to allow delete of llx_bank_url if ($result == 0) $accline->rowid = $bank_line_id; // If not found, we set artificially rowid to allow delete of llx_bank_url
// Delete bank account url lines linked to payment // Delete bank account url lines linked to payment
$result=$accline->delete_urls($user); $result = $accline->delete_urls($user);
if ($result < 0) if ($result < 0)
{ {
$this->error=$accline->error; $this->error = $accline->error;
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
// Delete bank account lines linked to payment // Delete bank account lines linked to payment
$result=$accline->delete($user); $result = $accline->delete($user);
if ($result < 0) if ($result < 0)
{ {
$this->error=$accline->error; $this->error = $accline->error;
$this->db->rollback(); $this->db->rollback();
return -4; return -4;
} }
} }
if (! $notrigger) if (!$notrigger)
{ {
// Call triggers // Call triggers
$result=$this->call_trigger('PAYMENT_CUSTOMER_DELETE', $user); $result = $this->call_trigger('PAYMENT_CUSTOMER_DELETE', $user);
if ($result < 0) if ($result < 0)
{ {
$this->db->rollback(); $this->db->rollback();
@ -549,18 +549,18 @@ class Paiement extends CommonObject
// Delete payment (into paiement_facture and paiement) // Delete payment (into paiement_facture and paiement)
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement_facture';
$sql.= ' WHERE fk_paiement = '.$this->id; $sql .= ' WHERE fk_paiement = '.$this->id;
dol_syslog($sql); dol_syslog($sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement'; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'paiement';
$sql.= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
dol_syslog($sql); dol_syslog($sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (!$result)
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -3; return -3;
} }
@ -570,7 +570,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->error; $this->error = $this->db->error;
$this->db->rollback(); $this->db->rollback();
return -5; return -5;
} }
@ -642,7 +642,7 @@ class Paiement extends CommonObject
// On connait ainsi le paiement qui a genere l'ecriture bancaire // On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0) if ($bank_line_id > 0)
{ {
$result=$this->update_fk_bank($bank_line_id); $result = $this->update_fk_bank($bank_line_id);
if ($result <= 0) if ($result <= 0)
{ {
$error++; $error++;
@ -650,14 +650,14 @@ class Paiement extends CommonObject
} }
// Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction // Add link 'payment', 'payment_supplier' in bank_url between payment and bank transaction
if ( ! $error) if (!$error)
{ {
$url=''; $url = '';
if ($mode == 'payment') $url=DOL_URL_ROOT.'/compta/paiement/card.php?id='; if ($mode == 'payment') $url = DOL_URL_ROOT.'/compta/paiement/card.php?id=';
if ($mode == 'payment_supplier') $url=DOL_URL_ROOT.'/fourn/paiement/card.php?id='; if ($mode == 'payment_supplier') $url = DOL_URL_ROOT.'/fourn/paiement/card.php?id=';
if ($url) if ($url)
{ {
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
if ($result <= 0) if ($result <= 0)
{ {
$error++; $error++;
@ -668,9 +668,9 @@ class Paiement extends CommonObject
// Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
//if (! $error && $label != '(WithdrawalPayment)') //if (! $error && $label != '(WithdrawalPayment)')
if (! $error) if (!$error)
{ {
$linkaddedforthirdparty=array(); $linkaddedforthirdparty = array();
foreach ($this->amounts as $key => $value) // We should have invoices always for same third party but we loop in case of. foreach ($this->amounts as $key => $value) // We should have invoices always for same third party but we loop in case of.
{ {
if ($mode == 'payment') if ($mode == 'payment')
@ -678,9 +678,9 @@ class Paiement extends CommonObject
$fac = new Facture($this->db); $fac = new Facture($this->db);
$fac->fetch($key); $fac->fetch($key);
$fac->fetch_thirdparty(); $fac->fetch_thirdparty();
if (! in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty
{ {
$result=$acc->add_url_line( $result = $acc->add_url_line(
$bank_line_id, $bank_line_id,
$fac->thirdparty->id, $fac->thirdparty->id,
DOL_URL_ROOT.'/comm/card.php?socid=', DOL_URL_ROOT.'/comm/card.php?socid=',
@ -688,7 +688,7 @@ class Paiement extends CommonObject
'company' 'company'
); );
if ($result <= 0) dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror()); if ($result <= 0) dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror());
$linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id; // Mark as done for this thirdparty
} }
} }
if ($mode == 'payment_supplier') if ($mode == 'payment_supplier')
@ -696,9 +696,9 @@ class Paiement extends CommonObject
$fac = new FactureFournisseur($this->db); $fac = new FactureFournisseur($this->db);
$fac->fetch($key); $fac->fetch($key);
$fac->fetch_thirdparty(); $fac->fetch_thirdparty();
if (! in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) // Not yet done for this thirdparty
{ {
$result=$acc->add_url_line( $result = $acc->add_url_line(
$bank_line_id, $bank_line_id,
$fac->thirdparty->id, $fac->thirdparty->id,
DOL_URL_ROOT.'/fourn/card.php?socid=', DOL_URL_ROOT.'/fourn/card.php?socid=',
@ -706,15 +706,15 @@ class Paiement extends CommonObject
'company' 'company'
); );
if ($result <= 0) dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror()); if ($result <= 0) dol_syslog(get_class($this).'::addPaymentToBank '.$this->db->lasterror());
$linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id; // Mark as done for this thirdparty
} }
} }
} }
} }
// Add link 'WithdrawalPayment' in bank_url // Add link 'WithdrawalPayment' in bank_url
if (! $error && $label == '(WithdrawalPayment)') { if (!$error && $label == '(WithdrawalPayment)') {
$result=$acc->add_url_line( $result = $acc->add_url_line(
$bank_line_id, $bank_line_id,
$this->id_prelevement, $this->id_prelevement,
DOL_URL_ROOT.'/compta/prelevement/card.php?id=', DOL_URL_ROOT.'/compta/prelevement/card.php?id=',
@ -723,21 +723,21 @@ class Paiement extends CommonObject
); );
} }
if (! $error && ! $notrigger) if (!$error && !$notrigger)
{ {
// Appel des triggers // Appel des triggers
$result=$this->call_trigger('PAYMENT_ADD_TO_BANK', $user); $result = $this->call_trigger('PAYMENT_ADD_TO_BANK', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// Fin appel triggers // Fin appel triggers
} }
} }
else else
{ {
$this->error=$acc->error; $this->error = $acc->error;
$error++; $error++;
} }
if (! $error) if (!$error)
{ {
$this->db->commit(); $this->db->commit();
} }
@ -747,7 +747,7 @@ class Paiement extends CommonObject
} }
} }
if (! $error) if (!$error)
{ {
return $bank_line_id; return $bank_line_id;
} }
@ -769,7 +769,7 @@ class Paiement extends CommonObject
{ {
// phpcs:enable // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG); dol_syslog(get_class($this).'::update_fk_bank', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -779,7 +779,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::update_fk_bank '.$this->error); dol_syslog(get_class($this).'::update_fk_bank '.$this->error);
return -1; return -1;
} }
@ -795,7 +795,7 @@ class Paiement extends CommonObject
public function update_date($date) public function update_date($date)
{ {
// phpcs:enable // phpcs:enable
$error=0; $error = 0;
if (!empty($date) && $this->statut != 1) if (!empty($date) && $this->statut != 1)
{ {
@ -804,35 +804,35 @@ class Paiement extends CommonObject
dol_syslog(get_class($this)."::update_date with date = ".$date, LOG_DEBUG); dol_syslog(get_class($this)."::update_date with date = ".$date, LOG_DEBUG);
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET datep = '".$this->db->idate($date)."'"; $sql .= " SET datep = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (!$result)
{ {
$error++; $error++;
$this->error='Error -1 '.$this->db->error(); $this->error = 'Error -1 '.$this->db->error();
} }
$type = $this->element; $type = $this->element;
$sql = "UPDATE ".MAIN_DB_PREFIX.'bank'; $sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
$sql.= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'"; $sql .= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")"; $sql .= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$type."' AND url_id = ".$this->id.")";
$sql.= " AND rappro = 0"; $sql .= " AND rappro = 0";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (!$result)
{ {
$error++; $error++;
$this->error='Error -1 '.$this->db->error(); $this->error = 'Error -1 '.$this->db->error();
} }
if (! $error) if (!$error)
{ {
} }
if (! $error) if (!$error)
{ {
$this->datepaye = $date; $this->datepaye = $date;
$this->date = $date; $this->date = $date;
@ -859,10 +859,10 @@ class Paiement extends CommonObject
public function update_num($num) public function update_num($num)
{ {
// phpcs:enable // phpcs:enable
if(!empty($num) && $this->statut!=1) { if (!empty($num) && $this->statut != 1) {
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET num_paiement = '".$this->db->escape($num)."'"; $sql .= " SET num_paiement = '".$this->db->escape($num)."'";
$sql.= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_num", LOG_DEBUG); dol_syslog(get_class($this)."::update_num", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -873,7 +873,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error='Error -1 '.$this->db->error(); $this->error = 'Error -1 '.$this->db->error();
return -2; return -2;
} }
} }
@ -898,7 +898,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::valide '.$this->error); dol_syslog(get_class($this).'::valide '.$this->error);
return -1; return -1;
} }
@ -922,7 +922,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->lasterror(); $this->error = $this->db->lasterror();
dol_syslog(get_class($this).'::reject '.$this->error); dol_syslog(get_class($this).'::reject '.$this->error);
return -1; return -1;
} }
@ -937,8 +937,8 @@ class Paiement extends CommonObject
public function info($id) public function info($id)
{ {
$sql = 'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms'; $sql = 'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p';
$sql.= ' WHERE p.rowid = '.$id; $sql .= ' WHERE p.rowid = '.$id;
dol_syslog(get_class($this).'::info', LOG_DEBUG); dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -953,7 +953,7 @@ class Paiement extends CommonObject
{ {
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_creat); $cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_modif) if ($obj->fk_user_modif)
{ {
@ -981,20 +981,20 @@ class Paiement extends CommonObject
public function getBillsArray($filter = '') public function getBillsArray($filter = '')
{ {
$sql = 'SELECT pf.fk_facture'; $sql = 'SELECT pf.fk_facture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; // We keep link on invoice to allow use of some filters on invoice $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; // We keep link on invoice to allow use of some filters on invoice
$sql.= ' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id; $sql .= ' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id;
if ($filter) $sql.= ' AND '.$filter; if ($filter) $sql .= ' AND '.$filter;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$i=0; $i = 0;
$num=$this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$billsarray=array(); $billsarray = array();
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$billsarray[$i]=$obj->fk_facture; $billsarray[$i] = $obj->fk_facture;
$i++; $i++;
} }
@ -1002,7 +1002,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->error(); $this->error = $this->db->error();
dol_syslog(get_class($this).'::getBillsArray Error '.$this->error.' -', LOG_DEBUG); dol_syslog(get_class($this).'::getBillsArray Error '.$this->error.' -', LOG_DEBUG);
return -1; return -1;
} }
@ -1016,19 +1016,19 @@ class Paiement extends CommonObject
public function getAmountsArray() public function getAmountsArray()
{ {
$sql = 'SELECT pf.fk_facture, pf.amount'; $sql = 'SELECT pf.fk_facture, pf.amount';
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf';
$sql.= ' WHERE pf.fk_paiement = '.$this->id; $sql .= ' WHERE pf.fk_paiement = '.$this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$i=0; $i = 0;
$num=$this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$amounts = array(); $amounts = array();
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$amounts[$obj->fk_facture]=$obj->amount; $amounts[$obj->fk_facture] = $obj->amount;
$i++; $i++;
} }
@ -1036,7 +1036,7 @@ class Paiement extends CommonObject
} }
else else
{ {
$this->error=$this->db->error(); $this->error = $this->db->error();
dol_syslog(get_class($this).'::getAmountsArray Error '.$this->error.' -', LOG_DEBUG); dol_syslog(get_class($this).'::getAmountsArray Error '.$this->error.' -', LOG_DEBUG);
return -1; return -1;
} }
@ -1056,13 +1056,13 @@ class Paiement extends CommonObject
$langs->load("bills"); $langs->load("bills");
// Clean parameters (if not defined or using deprecated value) // Clean parameters (if not defined or using deprecated value)
if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON='mod_payment_cicada'; if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON = 'mod_payment_cicada';
elseif ($conf->global->PAYMENT_ADDON=='ant') $conf->global->PAYMENT_ADDON='mod_payment_ant'; elseif ($conf->global->PAYMENT_ADDON == 'ant') $conf->global->PAYMENT_ADDON = 'mod_payment_ant';
elseif ($conf->global->PAYMENT_ADDON=='cicada') $conf->global->PAYMENT_ADDON='mod_payment_cicada'; elseif ($conf->global->PAYMENT_ADDON == 'cicada') $conf->global->PAYMENT_ADDON = 'mod_payment_cicada';
if (! empty($conf->global->PAYMENT_ADDON)) if (!empty($conf->global->PAYMENT_ADDON))
{ {
$mybool=false; $mybool = false;
$file = $conf->global->PAYMENT_ADDON.".php"; $file = $conf->global->PAYMENT_ADDON.".php";
$classname = $conf->global->PAYMENT_ADDON; $classname = $conf->global->PAYMENT_ADDON;
@ -1076,12 +1076,12 @@ class Paiement extends CommonObject
// Load file with numbering class (if found) // Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) if (is_file($dir.$file) && is_readable($dir.$file))
{ {
$mybool |= include_once $dir . $file; $mybool |= include_once $dir.$file;
} }
} }
// For compatibility // For compatibility
if (! $mybool) if (!$mybool)
{ {
$file = $conf->global->PAYMENT_ADDON.".php"; $file = $conf->global->PAYMENT_ADDON.".php";
$classname = "mod_payment_".$conf->global->PAYMENT_ADDON; $classname = "mod_payment_".$conf->global->PAYMENT_ADDON;
@ -1093,12 +1093,12 @@ class Paiement extends CommonObject
// Load file with numbering class (if found) // Load file with numbering class (if found)
if (is_file($dir.$file) && is_readable($dir.$file)) { if (is_file($dir.$file) && is_readable($dir.$file)) {
$mybool |= include_once $dir . $file; $mybool |= include_once $dir.$file;
} }
} }
} }
if (! $mybool) if (!$mybool)
{ {
dol_print_error('', "Failed to include file ".$file); dol_print_error('', "Failed to include file ".$file);
return ''; return '';
@ -1162,16 +1162,16 @@ class Paiement extends CommonObject
*/ */
public function initAsSpecimen($option = '') public function initAsSpecimen($option = '')
{ {
global $user,$langs,$conf; global $user, $langs, $conf;
$now=dol_now(); $now = dol_now();
$arraynow=dol_getdate($now); $arraynow = dol_getdate($now);
$nownotime=dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
// Initialize parameters // Initialize parameters
$this->id=0; $this->id = 0;
$this->ref = 'SPECIMEN'; $this->ref = 'SPECIMEN';
$this->specimen=1; $this->specimen = 1;
$this->facid = 1; $this->facid = 1;
$this->datepaye = $nownotime; $this->datepaye = $nownotime;
} }
@ -1190,49 +1190,49 @@ class Paiement extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result=''; $result = '';
$label = '<u>'.$langs->trans("ShowPayment").'</u><br>'; $label = '<u>'.$langs->trans("ShowPayment").'</u><br>';
$label.= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref; $label .= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref;
if ($this->datepaye ? $this->datepaye : $this->date) $label.= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour'); if ($this->datepaye ? $this->datepaye : $this->date) $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
if ($mode == 'withlistofinvoices') if ($mode == 'withlistofinvoices')
{ {
$arraybill = $this->getBillsArray(); $arraybill = $this->getBillsArray();
if (is_array($arraybill) && count($arraybill) > 0) if (is_array($arraybill) && count($arraybill) > 0)
{ {
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($this->db); $facturestatic = new Facture($this->db);
foreach ($arraybill as $billid) foreach ($arraybill as $billid)
{ {
$facturestatic->fetch($billid); $facturestatic->fetch($billid);
$label .='<br> '.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2, 1); $label .= '<br> '.$facturestatic->getNomUrl(1).' '.$facturestatic->getLibStatut(2, 1);
} }
} }
} }
$linkclose=''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip))
{ {
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label=$langs->trans("ShowMyObject"); $label = $langs->trans("ShowMyObject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} }
else $linkclose = ($morecss?' class="'.$morecss.'"':''); else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$url = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$this->id;
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend='</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto && $withpicto != 2) $result.= ($this->ref?$this->ref:$this->id); if ($withpicto && $withpicto != 2) $result .= ($this->ref ? $this->ref : $this->id);
$result .= $linkend; $result .= $linkend;
return $result; return $result;
@ -1260,7 +1260,7 @@ class Paiement extends CommonObject
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta'); $langs->load('compta');
/*if ($mode == 0) /*if ($mode == 0)
@ -1311,7 +1311,7 @@ class Paiement extends CommonObject
public function fetch_thirdparty($force_thirdparty_id = 0) public function fetch_thirdparty($force_thirdparty_id = 0)
{ {
// phpcs:enable // phpcs:enable
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (empty($force_thirdparty_id)) if (empty($force_thirdparty_id))
{ {

View File

@ -6052,7 +6052,7 @@ class Form
// Search data // Search data
$sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX.$objecttmp->table_element." as t"; $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX.$objecttmp->table_element." as t";
if (isset($objecttmp->ismultientitymanaged) && ! is_numeric($objecttmp->ismultientitymanaged)) { if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
$tmparray = explode('@', $objecttmp->ismultientitymanaged); $tmparray = explode('@', $objecttmp->ismultientitymanaged);
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0]; $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
} }
@ -6060,7 +6060,7 @@ class Form
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE 1=1"; $sql .= " WHERE 1=1";
if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")"; if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
if (isset($objecttmp->ismultientitymanaged) && ! is_numeric($objecttmp->ismultientitymanaged)) { if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
$sql .= ' AND parenttable.entity = t.'.$tmparray[0]; $sql .= ' AND parenttable.entity = t.'.$tmparray[0];
} }
if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) { if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
@ -7321,21 +7321,21 @@ class Form
} }
elseif ($fieldref != 'none') elseif ($fieldref != 'none')
{ {
$ret.=dol_htmlentities($object->$fieldref); $ret .= dol_htmlentities($object->$fieldref);
} }
if ($morehtmlref) if ($morehtmlref)
{ {
// don't add a additional space, when "$morehtmlref" starts with a HTML div tag // don't add a additional space, when "$morehtmlref" starts with a HTML div tag
if(substr($morehtmlref, 0, 4) != '<div') if (substr($morehtmlref, 0, 4) != '<div')
{ {
$ret.=' '; $ret .= ' ';
} }
$ret.=$morehtmlref; $ret .= $morehtmlref;
} }
$ret.='</div>'; $ret .= '</div>';
$ret .= '</div><!-- End banner content -->'; $ret .= '</div><!-- End banner content -->';
@ -8077,8 +8077,8 @@ class Form
$ret .= '<div name="search_component_params" class="search_component_params inline-block minwidth500 maxwidth300onsmartphone">'; $ret .= '<div name="search_component_params" class="search_component_params inline-block minwidth500 maxwidth300onsmartphone">';
$ret .= '<input type="text" name="search_component_params_input" class="search_component_params_input" placeholder="'.$langs->trans("Search").'" value="'.GETPOST("search_component_params_input").'">'; $ret .= '<input type="text" name="search_component_params_input" class="search_component_params_input" placeholder="'.$langs->trans("Search").'" value="'.GETPOST("search_component_params_input").'">';
$ret .= '</div>'; $ret .= '</div>';
foreach($arrayofcriterias as $criterias) { foreach ($arrayofcriterias as $criterias) {
foreach($criterias as $criteriafamilykey => $criteriafamilyval) { foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue; if (in_array('search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) continue;
if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue; if (in_array($criteriafamilykey, array('rowid', 'ref_ext', 'entity', 'extraparams'))) continue;
if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) { if (in_array($criteriafamilyval['type'], array('date', 'datetime', 'timestamp'))) {

View File

@ -25,7 +25,7 @@
* \ingroup fournisseur * \ingroup fournisseur
* \brief Description and activation file for module Supplier * \brief Description and activation file for module Supplier
*/ */
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/** /**
@ -58,7 +58,7 @@ class modFournisseur extends DolibarrModules
$this->version = 'dolibarr'; $this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto='company'; $this->picto = 'company';
// Data directories to create when module is enabled // Data directories to create when module is enabled
$this->dirs = array( $this->dirs = array(
@ -79,7 +79,7 @@ class modFournisseur extends DolibarrModules
// Constants // Constants
$this->const = array(); $this->const = array();
$r=0; $r = 0;
$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF"; $this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
@ -120,19 +120,19 @@ class modFournisseur extends DolibarrModules
// Boxes // Boxes
$this->boxes = array( $this->boxes = array(
0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'), 0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
1=>array('file'=>'box_graph_orders_supplier_permonth.php','enabledbydefaulton'=>'Home'), 1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
2=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'), 2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'),
3=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'), 3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'),
4=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'), 4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'),
5=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'), 5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'),
6=>array('file'=>'box_supplier_orders_awaiting_reception.php','enabledbydefaulton'=>'Home'), 6=>array('file'=>'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton'=>'Home'),
); );
// Permissions // Permissions
$this->rights = array(); $this->rights = array();
$this->rights_class = 'fournisseur'; $this->rights_class = 'fournisseur';
$r=0; $r = 0;
$r++; $r++;
$this->rights[$r][0] = 1181; $this->rights[$r][0] = 1181;
@ -205,11 +205,11 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][4] = 'commande'; $this->rights[$r][4] = 'commande';
$this->rights[$r][5] = 'supprimer'; $this->rights[$r][5] = 'supprimer';
if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
{ {
$r++; $r++;
$this->rights[$r][0] = 1190; $this->rights[$r][0] = 1190;
$this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190"); $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190");
$this->rights[$r][2] = 'w'; $this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'commande'; $this->rights[$r][4] = 'commande';
@ -275,28 +275,28 @@ class modFournisseur extends DolibarrModules
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
//-------- //--------
$r=0; $r = 0;
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='Vendor invoices and lines of invoices'; $this->export_label[$r] = 'Vendor invoices and lines of invoices';
$this->export_icon[$r]='bill'; $this->export_icon[$r] = 'bill';
$this->export_permission[$r]=array(array("fournisseur","facture","export")); $this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r] = array(
's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone', 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>'DateMaxPayment', 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>'DateMaxPayment',
'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote",
'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT", 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT",
'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId', 'fd.total_ttc'=>"LineTotalTTC", 'fd.tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.fk_product'=>'ProductId',
'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',
'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel' 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
); );
//$this->export_TypeFields_array[$r]=array( //$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text', // 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',
@ -304,123 +304,123 @@ class modFournisseur extends DolibarrModules
// 'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric", // 'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",
// 'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text' // 'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
//); //);
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r] = array(
's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>'Date', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date',
'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'fd.description'=>"Text", 'fd.tva_tx'=>"Text",
'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label', 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.tva'=>"Numeric", 'fd.product_type'=>'Numeric', 'fd.fk_product'=>'List:product:label',
'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text' 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
); );
$this->export_entities_array[$r]=array( $this->export_entities_array[$r] = array(
's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company', 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company',
's.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice", 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company', 'f.rowid'=>"invoice",
'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>'invoice','f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice', 'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice",
'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line",
'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product', 'fd.remise_percent'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva'=>"invoice_line", 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product',
'p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project' 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_buy'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
); );
$this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object // Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$typeFilter="Text"; $typeFilter = "Text";
switch($obj->type) switch ($obj->type)
{ {
case 'int': case 'int':
case 'double': case 'double':
case 'price': case 'price':
$typeFilter="Numeric"; $typeFilter = "Numeric";
break; break;
case 'date': case 'date':
case 'datetime': case 'datetime':
$typeFilter="Date"; $typeFilter = "Date";
break; break;
case 'boolean': case 'boolean':
$typeFilter="Boolean"; $typeFilter = "Boolean";
break; break;
case 'sellist': case 'sellist':
$tmp=''; $tmp = '';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break; break;
} }
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice'; $this->export_entities_array[$r][$fieldname] = 'invoice';
} }
} }
// End add extra fields // End add extra fields
// Add extra fields line // Add extra fields line
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$fieldname='extraline.'.$obj->name; $fieldname = 'extraline.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$typeFilter="Text"; $typeFilter = "Text";
switch($obj->type) switch ($obj->type)
{ {
case 'int': case 'int':
case 'double': case 'double':
case 'price': case 'price':
$typeFilter="Numeric"; $typeFilter = "Numeric";
break; break;
case 'date': case 'date':
case 'datetime': case 'datetime':
$typeFilter="Date"; $typeFilter = "Date";
break; break;
case 'boolean': case 'boolean':
$typeFilter="Boolean"; $typeFilter = "Boolean";
break; break;
case 'sellist': case 'sellist':
$tmp=''; $tmp = '';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break; break;
} }
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice_line'; $this->export_entities_array[$r][$fieldname] = 'invoice_line';
} }
} }
// End add extra fields line // End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd'; $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='Factures fournisseurs et reglements'; $this->export_label[$r] = 'Factures fournisseurs et reglements';
$this->export_icon[$r]='bill'; $this->export_icon[$r] = 'bill';
$this->export_permission[$r]=array(array("fournisseur","facture","export")); $this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r] = array(
's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone', 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation", 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation",
'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid", 'f.datef'=>"DateInvoice", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid",
'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment', 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment',
'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel' 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
); );
//$this->export_TypeFields_array[$r]=array( //$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text', // 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
@ -428,201 +428,201 @@ class modFournisseur extends DolibarrModules
// 'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text", // 'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",
// 'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric' // 'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric'
//); //);
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r] = array(
's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text', 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text',
's.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric", 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.total_ht'=>"Numeric",
'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Numeric', 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'pf.amount'=>'Numeric',
'p.datep'=>'Date','p.num_paiement'=>'Numeric','project.ref'=>'Text','project.title'=>'Text' 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', 'project.ref'=>'Text', 'project.title'=>'Text'
); );
$this->export_entities_array[$r]=array( $this->export_entities_array[$r] = array(
's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company', 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice", 'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.total_ht'=>"invoice",
'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment', 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment',
'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'); 'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project');
$this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_dependencies_array[$r] = array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object // Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$typeFilter="Text"; $typeFilter = "Text";
switch($obj->type) switch ($obj->type)
{ {
case 'int': case 'int':
case 'double': case 'double':
case 'price': case 'price':
$typeFilter="Numeric"; $typeFilter = "Numeric";
break; break;
case 'date': case 'date':
case 'datetime': case 'datetime':
$typeFilter="Date"; $typeFilter = "Date";
break; break;
case 'boolean': case 'boolean':
$typeFilter="Boolean"; $typeFilter = "Boolean";
break; break;
case 'sellist': case 'sellist':
$tmp=''; $tmp = '';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options'])); if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break; break;
} }
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname]='invoice'; $this->export_entities_array[$r][$fieldname] = 'invoice';
} }
} }
// End add extra fields object // End add extra fields object
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
// Order // Order
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='Purchase Orders and lines of purchase orders'; $this->export_label[$r] = 'Purchase Orders and lines of purchase orders';
$this->export_icon[$r]='order'; $this->export_icon[$r] = 'order';
$this->export_permission[$r]=array(array("fournisseur","commande","export")); $this->export_permission[$r] = array(array("fournisseur", "commande", "export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r] = array(
's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone', 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned", 'f.rowid'=>"OrderId", 'f.ref'=>"Ref", 'f.ref_supplier'=>"RefSupplier", 'f.date_creation'=>"DateCreation", 'f.date_commande'=>"OrderDate", 'f.date_livraison'=>"DateDeliveryPlanned",
'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2', 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',
'f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription", 'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC",
'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId', 'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',
'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel' 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
); );
if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
{ {
unset($this->export_fields_array['f.date_approve2']); unset($this->export_fields_array['f.date_approve2']);
unset($this->export_fields_array['ua2.login']); unset($this->export_fields_array['ua2.login']);
} }
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r] = array(
's.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text', 's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text", 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text",
'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric", 'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric",
'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text", 'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",
'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric", 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_tva'=>"Numeric",
'fd.product_type'=>'Numeric','fd.ref'=>'Text','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text' 'fd.product_type'=>'Numeric', 'fd.ref'=>'Text', 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
); );
$this->export_entities_array[$r]=array( $this->export_entities_array[$r] = array(
's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company', 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company',
's.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'ua1.login'=>'user',
'ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line", 'ua2.login'=>'user', 'fd.rowid'=>'order_line', 'fd.description'=>"order_line", 'fd.tva_tx'=>"order_line", 'fd.qty'=>"order_line", 'fd.remise_percent'=>"order_line",
'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.ref'=>'order_line','fd.fk_product'=>'product', 'fd.total_ht'=>"order_line", 'fd.total_ttc'=>"order_line", 'fd.total_tva'=>"order_line", 'fd.product_type'=>'order_line', 'fd.ref'=>'order_line', 'fd.fk_product'=>'product',
'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project' 'p.ref'=>'product', 'p.label'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
); );
$this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_dependencies_array[$r] = array('order_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object // Add extra fields object
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")";
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname = 'extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$typeFilter="Text"; $typeFilter = "Text";
switch($obj->type) switch ($obj->type)
{ {
case 'int': case 'int':
case 'double': case 'double':
case 'price': case 'price':
$typeFilter="Numeric"; $typeFilter = "Numeric";
break; break;
case 'date': case 'date':
case 'datetime': case 'datetime':
$typeFilter="Date"; $typeFilter = "Date";
break; break;
case 'boolean': case 'boolean':
$typeFilter="Boolean"; $typeFilter = "Boolean";
break; break;
case 'sellist': case 'sellist':
$tmp=''; $tmp = '';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
$tmpkey=array_keys($tmpparam['options']); $tmpkey = array_keys($tmpparam['options']);
if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey); if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift($tmpkey);
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break; break;
} }
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname]='order'; $this->export_entities_array[$r][$fieldname] = 'order';
} }
} }
// End add extra fields object // End add extra fields object
// Add extra fields line // Add extra fields line
$sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")"; $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")";
$resql=$this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$fieldname='extraline.'.$obj->name; $fieldname = 'extraline.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel = ucfirst($obj->label);
$typeFilter="Text"; $typeFilter = "Text";
switch($obj->type) switch ($obj->type)
{ {
case 'int': case 'int':
case 'double': case 'double':
case 'price': case 'price':
$typeFilter="Numeric"; $typeFilter = "Numeric";
break; break;
case 'date': case 'date':
case 'datetime': case 'datetime':
$typeFilter="Date"; $typeFilter = "Date";
break; break;
case 'boolean': case 'boolean':
$typeFilter="Boolean"; $typeFilter = "Boolean";
break; break;
case 'sellist': case 'sellist':
$tmp=''; $tmp = '';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) { if ($tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpparam_param_key=array_keys($tmpparam['options']); $tmpparam_param_key = array_keys($tmpparam['options']);
$tmp=array_shift($tmpparam_param_key); $tmp = array_shift($tmpparam_param_key);
} }
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp; if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break; break;
} }
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname] = $fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
$this->export_entities_array[$r][$fieldname]='order_line'; $this->export_entities_array[$r][$fieldname] = 'order_line';
} }
} }
// End add extra fields line // End add extra fields line
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
$this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
$this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
} }
@ -641,19 +641,19 @@ class modFournisseur extends DolibarrModules
$this->remove($options); $this->remove($options);
//ODT template //ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt'; $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_orders'; $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_orders';
$dest=$dirodt.'/template_supplier_order.odt'; $dest = $dirodt.'/template_supplier_order.odt';
if (file_exists($src) && ! file_exists($dest)) if (file_exists($src) && !file_exists($dest))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt); dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0); $result = dol_copy($src, $dest, 0, 0);
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0; return 0;
} }
} }

View File

@ -247,39 +247,39 @@ class modSociete extends DolibarrModules
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
//-------- //--------
$r=0; $r = 0;
// Export list of third parties and attributes // Export list of third parties and attributes
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='ExportDataset_company_1'; $this->export_label[$r] = 'ExportDataset_company_1';
$this->export_icon[$r]='company'; $this->export_icon[$r] = 'company';
$this->export_permission[$r]=array(array("societe","export")); $this->export_permission[$r] = array(array("societe", "export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r] = array(
's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNameShort",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification", 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification",
's.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
's.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax", 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax",
's.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4", 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4",
's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic", 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic",
't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel', 't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel',
'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode' 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode'
); );
if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix'; if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix';
if (! empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level']='PriceLevel'; if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel';
// Add multicompany field // Add multicompany field
if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
{ {
$nbofallowedentities=count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1 $nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity'); if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity');
} }
$keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra'; $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname');
//$this->export_TypeFields_array[$r]=array( //$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", // 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
// 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label", // 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",
@ -288,104 +288,104 @@ class modSociete extends DolibarrModules
// 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', // 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
// 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid' // 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'
//); //);
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r] = array(
's.rowid'=>"Numeric", 's.nom'=>"Text",'s.name_alias'=>"Text",'s.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date", 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date",
's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text",
's.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",
's.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text", 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text",
's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text",
'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code', 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
'st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text', 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text',
'paymode.libelle'=>'Text','s.entity'=>'Numeric', 'paymode.libelle'=>'Text', 's.entity'=>'Numeric',
's.price_level'=>'Numeric' 's.price_level'=>'Numeric'
); );
$this->export_entities_array[$r]=array('u.login'=>'user','u.firstname'=>'user','u.lastname'=>'user'); // We define here only fields that use another picto $this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto
$this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id';
$this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')'; $this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) { if (is_object($user) && empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
$subordinatesids = $user->getAllChildIds(); $subordinatesids = $user->getAllChildIds();
$this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : ''; $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
} }
$this->export_sql_end[$r] .=')'; $this->export_sql_end[$r] .= ')';
} }
// Export list of contacts and attributes // Export list of contacts and attributes
$r++; $r++;
$this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r]='ExportDataset_company_2'; $this->export_label[$r] = 'ExportDataset_company_2';
$this->export_icon[$r]='contact'; $this->export_icon[$r] = 'contact';
$this->export_permission[$r]=array(array("societe","contact","export")); $this->export_permission[$r] = array(array("societe", "contact", "export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r] = array(
'c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction', 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction',
'c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town", 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town",
'd.nom'=>'State','co.label'=>"Country",'co.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail", 'd.nom'=>'State', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail",
'c.statut'=>"Status", 'c.statut'=>"Status",
's.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode", 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode",
's.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
's.client'=>'Customer','s.fournisseur'=>'Supplier', 's.client'=>'Customer', 's.fournisseur'=>'Supplier',
's.address'=>'Address','s.zip'=>"Zip",'s.town'=>"Town",'s.phone'=>'Phone','s.email'=>"Email", 's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email",
't.libelle'=>"ThirdPartyType" 't.libelle'=>"ThirdPartyType"
); );
$this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r] = array(
'c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean", 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean",
'c.address'=>"Text",'c.zip'=>"Text",'c.town'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text", 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text",
'c.fax'=>"Text",'c.email'=>"Text", 'c.fax'=>"Text", 'c.email'=>"Text",
'c.statut'=>"Status", 'c.statut'=>"Status",
's.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text", 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",
's.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",
's.client'=>"Text",'s.fournisseur'=>"Text", 's.client'=>"Text", 's.fournisseur'=>"Text",
's.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'s.phone'=>"Text",'s.email'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text",
't.libelle'=>"Text" 't.libelle'=>"Text"
); );
$this->export_entities_array[$r]=array( $this->export_entities_array[$r] = array(
's.rowid'=>"company",'s.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company",'s.code_fournisseur'=>"company", 's.rowid'=>"company", 's.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company", 's.code_fournisseur'=>"company",
's.code_compta'=>"company",'s.code_compta_fournisseur'=>"company", 's.code_compta'=>"company", 's.code_compta_fournisseur'=>"company",
's.client'=>"company", 's.fournisseur'=>"company", 's.client'=>"company", 's.fournisseur'=>"company",
's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company",
't.libelle'=>"company" 't.libelle'=>"company"
); // We define here only fields that use another picto ); // We define here only fields that use another picto
if (empty($conf->fournisseur->enabled)) if (empty($conf->fournisseur->enabled))
{ {
unset($this->export_fields_array[$r]['s.code_fournisseur']); unset($this->export_fields_array[$r]['s.code_fournisseur']);
unset($this->export_entities_array[$r]['s.code_fournisseur']); unset($this->export_entities_array[$r]['s.code_fournisseur']);
} }
$keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra'; $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extrasoc'; $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
$this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')'; $this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('socpeople').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) { if (is_object($user) && empty($user->rights->societe->client->voir)) {
$this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
$subordinatesids = $user->getAllChildIds(); $subordinatesids = $user->getAllChildIds();
$this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : ''; $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
} }
$this->export_sql_end[$r] .=')'; $this->export_sql_end[$r] .= ')';
} }

View File

@ -34,27 +34,27 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
if (! empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; if (!empty($conf->supplier_proposal->enabled)) require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (! empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; if (!empty($conf->expedition->enabled)) require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; if (!empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (!empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; if (!empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; if (!empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php';
if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; if (!empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
if (! empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; if (!empty($conf->tax->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
if (! empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
if (! empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; if (!empty($conf->salaries->enabled)) require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('projects', 'companies', 'suppliers', 'compta')); $langs->loadLangs(array('projects', 'companies', 'suppliers', 'compta'));
@ -652,25 +652,25 @@ foreach ($listofreferent as $key => $value)
$total_ht_by_line = price2num($tmp['amount'], 'MT'); $total_ht_by_line = price2num($tmp['amount'], 'MT');
} }
} }
elseif ($key == 'loan'){ elseif ($key == 'loan') {
if((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)){ if ((empty($dates) && empty($datee)) || (intval($dates) <= $element->datestart && intval($datee) >= $element->dateend)) {
// Get total loan // Get total loan
$total_ht_by_line = -$element->capital; $total_ht_by_line = -$element->capital;
} }
else{ else {
// Get loan schedule according to date filter // Get loan schedule according to date filter
$total_ht_by_line = 0; $total_ht_by_line = 0;
$loanScheduleStatic = new LoanSchedule($element->db); $loanScheduleStatic = new LoanSchedule($element->db);
$loanScheduleStatic->fetchAll($element->id); $loanScheduleStatic->fetchAll($element->id);
if(!empty($loanScheduleStatic->lines)){ if (!empty($loanScheduleStatic->lines)) {
foreach($loanScheduleStatic->lines as $loanSchedule){ foreach ($loanScheduleStatic->lines as $loanSchedule) {
/** /**
* @var $loanSchedule LoanSchedule * @var $loanSchedule LoanSchedule
*/ */
if( ($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined if (($loanSchedule->datep >= $dates && $loanSchedule->datep <= $datee) // dates filter is defined
|| !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now() || !empty($dates) && empty($datee) && $loanSchedule->datep >= $dates && $loanSchedule->datep <= dol_now()
|| empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee || empty($dates) && !empty($datee) && $loanSchedule->datep <= $datee
){ ) {
$total_ht_by_line = -$loanSchedule->amount_capital; $total_ht_by_line = -$loanSchedule->amount_capital;
} }
} }
@ -688,7 +688,7 @@ foreach ($listofreferent as $key => $value)
$defaultvat = get_default_tva($mysoc, $mysoc); $defaultvat = get_default_tva($mysoc, $mysoc);
$total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT'); $total_ttc_by_line = price2num($total_ht_by_line * (1 + ($defaultvat / 100)), 'MT');
} }
elseif ($key == 'loan'){ elseif ($key == 'loan') {
$total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr $total_ttc_by_line = $total_ht_by_line; // For loan there is actually no taxe managed in Dolibarr
} }
else $total_ttc_by_line = $element->total_ttc; else $total_ttc_by_line = $element->total_ttc;
@ -968,7 +968,7 @@ foreach ($listofreferent as $key => $value)
print $element->getNomUrl(1, 'withproject', 'time'); print $element->getNomUrl(1, 'withproject', 'time');
print ' - '.dol_trunc($element->label, 48); print ' - '.dol_trunc($element->label, 48);
} }
elseif ($key == 'loan'){ elseif ($key == 'loan') {
print $element->getNomUrl(1); print $element->getNomUrl(1);
print ' - '.dol_trunc($element->label, 48); print ' - '.dol_trunc($element->label, 48);
} }
@ -1021,7 +1021,7 @@ foreach ($listofreferent as $key => $value)
if (empty($date)) $date = $element->datev; if (empty($date)) $date = $element->datev;
} }
} }
elseif ($key == 'loan'){ elseif ($key == 'loan') {
$date = $element->datestart; $date = $element->datestart;
} }