manage invoice with multicompany
This commit is contained in:
parent
0d443c434e
commit
8e51204dff
@ -947,7 +947,7 @@ class Facture extends CommonInvoice
|
|||||||
*/
|
*/
|
||||||
function createFromClone($socid=0)
|
function createFromClone($socid=0)
|
||||||
{
|
{
|
||||||
global $user,$hookmanager;
|
global $user,$hookmanager, $conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -996,6 +996,7 @@ class Facture extends CommonInvoice
|
|||||||
$this->close_code = '';
|
$this->close_code = '';
|
||||||
$this->close_note = '';
|
$this->close_note = '';
|
||||||
$this->products = $this->lines; // Tant que products encore utilise
|
$this->products = $this->lines; // Tant que products encore utilise
|
||||||
|
$this->entity = $conf->entity;
|
||||||
|
|
||||||
// Loop on each line of new invoice
|
// Loop on each line of new invoice
|
||||||
foreach($this->lines as $i => $line)
|
foreach($this->lines as $i => $line)
|
||||||
@ -3348,7 +3349,16 @@ class Facture extends CommonInvoice
|
|||||||
$mybool=false;
|
$mybool=false;
|
||||||
|
|
||||||
$file = $conf->global->FACTURE_ADDON.".php";
|
$file = $conf->global->FACTURE_ADDON.".php";
|
||||||
|
|
||||||
|
$constant = 'FACTURE_ADDON_'.$this->entity;
|
||||||
|
|
||||||
|
if (! empty($conf->global->$constant)) {
|
||||||
|
$classname = $conf->global->$constant; // for multicompany proposal sharing
|
||||||
|
} else {
|
||||||
$classname = $conf->global->FACTURE_ADDON;
|
$classname = $conf->global->FACTURE_ADDON;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Include file with class
|
// Include file with class
|
||||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
|
|||||||
@ -151,7 +151,7 @@ class mod_facture_mars extends ModeleNumRefFactures
|
|||||||
*/
|
*/
|
||||||
function getNextValue($objsoc, $invoice, $mode='next')
|
function getNextValue($objsoc, $invoice, $mode='next')
|
||||||
{
|
{
|
||||||
global $db;
|
global $db, $conf;
|
||||||
|
|
||||||
$prefix=$this->prefixinvoice;
|
$prefix=$this->prefixinvoice;
|
||||||
|
|
||||||
@ -160,12 +160,14 @@ class mod_facture_mars extends ModeleNumRefFactures
|
|||||||
else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
|
else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
|
||||||
else $prefix=$this->prefixinvoice;
|
else $prefix=$this->prefixinvoice;
|
||||||
|
|
||||||
|
$entity = ((isset($$invoice->entity) && is_numeric($$invoice->entity)) ? $$invoice->entity : $conf->entity);
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// D'abord on recupere la valeur max
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
||||||
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
$sql.= " AND entity = $entity";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||||
|
|||||||
@ -145,15 +145,46 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
|||||||
$mask = '';
|
$mask = '';
|
||||||
if (is_object($invoice) && $invoice->type == 1)
|
if (is_object($invoice) && $invoice->type == 1)
|
||||||
{
|
{
|
||||||
|
$constant = 'FACTURE_MERCURE_MASK_REPLACEMENT_'.$invoice->entity;
|
||||||
|
if (! empty($conf->global->$constant)) {
|
||||||
|
$mask = $conf->global->$constant; // for multicompany proposal sharing
|
||||||
|
} else {
|
||||||
$mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
|
$mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
|
||||||
|
}
|
||||||
if (! $mask)
|
if (! $mask)
|
||||||
{
|
{
|
||||||
|
$constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity;
|
||||||
|
if (! empty($conf->global->$constant)) {
|
||||||
|
$mask = $conf->global->$constant; // for multicompany proposal sharing
|
||||||
|
} else {
|
||||||
|
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_object($invoice) && $invoice->type == 2){
|
||||||
|
$constant = 'FACTURE_MERCURE_MASK_CREDIT_'.$invoice->entity;
|
||||||
|
if (! empty($conf->global->$constant)) {
|
||||||
|
$mask = $conf->global->$constant; // for multicompany proposal sharing
|
||||||
|
} else {
|
||||||
|
$mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_object($invoice) && $invoice->type == 3){
|
||||||
|
$constant = 'FACTURE_MERCURE_MASK_DEPOSIT_'.$invoice->entity;
|
||||||
|
if (! empty($conf->global->$constant)) {
|
||||||
|
$mask = $conf->global->$constant; // for multicompany proposal sharing
|
||||||
|
} else {
|
||||||
|
$mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$constant = 'FACTURE_MERCURE_MASK_INVOICE_'.$invoice->entity;
|
||||||
|
if (! empty($conf->global->$constant)) {
|
||||||
|
$mask = $conf->global->$constant; // for multicompany proposal sharing
|
||||||
|
} else {
|
||||||
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
|
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
|
|
||||||
else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
|
|
||||||
else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
|
|
||||||
if (! $mask)
|
if (! $mask)
|
||||||
{
|
{
|
||||||
$this->error='NotConfigured';
|
$this->error='NotConfigured';
|
||||||
|
|||||||
@ -175,12 +175,15 @@ class mod_facture_terre extends ModeleNumRefFactures
|
|||||||
else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
|
else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
|
||||||
else $prefix=$this->prefixinvoice;
|
else $prefix=$this->prefixinvoice;
|
||||||
|
|
||||||
|
// D'abord on recupere la valeur max
|
||||||
|
$entity = ((isset($invoice->entity) && is_numeric($invoice->entity)) ? $invoice->entity : $conf->entity);
|
||||||
|
|
||||||
// D'abord on recupere la valeur max
|
// D'abord on recupere la valeur max
|
||||||
$posindice=8;
|
$posindice=8;
|
||||||
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
||||||
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
$sql.= " AND entity = $entity";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user