Merge pull request #883 from marcosgdf/bug-846
Fixed bug #846: Create a supplier invoice (without project)
This commit is contained in:
commit
b721111409
@ -155,7 +155,7 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
$sql.= ", ".$this->socid;
|
$sql.= ", ".$this->socid;
|
||||||
$sql.= ", '".$this->db->idate($now)."'";
|
$sql.= ", '".$this->db->idate($now)."'";
|
||||||
$sql.= ", '".$this->db->idate($this->date)."'";
|
$sql.= ", '".$this->db->idate($this->date)."'";
|
||||||
$sql.= ", ".$this->fk_project;
|
$sql.= ", ".(isset($this->fk_project)?$this->fk_project:"null");
|
||||||
$sql.= ", '".$this->db->escape($this->note_private)."'";
|
$sql.= ", '".$this->db->escape($this->note_private)."'";
|
||||||
$sql.= ", '".$this->db->escape($this->note_public)."'";
|
$sql.= ", '".$this->db->escape($this->note_public)."'";
|
||||||
$sql.= ", ".$user->id.",";
|
$sql.= ", ".$user->id.",";
|
||||||
@ -167,14 +167,14 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn');
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn');
|
||||||
|
|
||||||
// Update ref with new one
|
// Update ref with new one
|
||||||
$this->ref='(PROV'.$this->id.')';
|
$this->ref='(PROV'.$this->id.')';
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture_fourn SET ref='".$this->ref."' WHERE rowid=".$this->id;
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture_fourn SET ref='".$this->ref."' WHERE rowid=".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if (! $resql) $error++;
|
if (! $resql) $error++;
|
||||||
|
|
||||||
// Add object linked
|
// Add object linked
|
||||||
if (! $error && $this->id && ! empty($this->origin) && ! empty($this->origin_id))
|
if (! $error && $this->id && ! empty($this->origin) && ! empty($this->origin_id))
|
||||||
@ -1350,8 +1350,8 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
global $db, $langs, $conf;
|
global $db, $langs, $conf;
|
||||||
$langs->load("orders");
|
$langs->load("orders");
|
||||||
|
|
||||||
// Clean parameters (if not defined or using deprecated value)
|
// Clean parameters (if not defined or using deprecated value)
|
||||||
if (empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER)) $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER='mod_facture_fournisseur_cactus';
|
if (empty($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER)) $conf->global->INVOICE_SUPPLIER_ADDON_NUMBER='mod_facture_fournisseur_cactus';
|
||||||
|
|
||||||
$mybool=false;
|
$mybool=false;
|
||||||
|
|
||||||
@ -1365,25 +1365,25 @@ class FactureFournisseur extends CommonInvoice
|
|||||||
$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 '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = new $classname();
|
$obj = new $classname();
|
||||||
|
|
||||||
$numref = "";
|
$numref = "";
|
||||||
$numref = $obj->getNumRef($soc,$this,$mode);
|
$numref = $obj->getNumRef($soc,$this,$mode);
|
||||||
|
|
||||||
if ( $numref != "")
|
if ( $numref != "")
|
||||||
{
|
{
|
||||||
return $numref;
|
return $numref;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
|
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -270,16 +270,18 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
|
|||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
$tmpproject = GETPOST('projectid', 'int');
|
||||||
|
|
||||||
// Creation facture
|
// Creation facture
|
||||||
$object->ref = $_POST['ref'];
|
$object->ref = $_POST['ref'];
|
||||||
$object->ref_supplier = $_POST['ref_supplier'];
|
$object->ref_supplier = $_POST['ref_supplier'];
|
||||||
$object->fk_project = GETPOST('projectid');
|
|
||||||
$object->socid = $_POST['socid'];
|
$object->socid = $_POST['socid'];
|
||||||
$object->libelle = $_POST['libelle'];
|
$object->libelle = $_POST['libelle'];
|
||||||
$object->date = $datefacture;
|
$object->date = $datefacture;
|
||||||
$object->date_echeance = $datedue;
|
$object->date_echeance = $datedue;
|
||||||
$object->note_public = GETPOST('note_public');
|
$object->note_public = GETPOST('note_public');
|
||||||
$object->note_private = GETPOST('note_private');
|
$object->note_private = GETPOST('note_private');
|
||||||
|
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
|
||||||
|
|
||||||
// If creation from another object of another module
|
// If creation from another object of another module
|
||||||
if ($_POST['origin'] && $_POST['originid'])
|
if ($_POST['origin'] && $_POST['originid'])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user