Merge pull request #883 from marcosgdf/bug-846

Fixed bug #846: Create a supplier invoice (without project)
This commit is contained in:
Laurent Destailleur 2013-04-26 13:05:52 -07:00
commit b721111409
2 changed files with 31 additions and 29 deletions

View File

@ -155,7 +155,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", ".$this->socid;
$sql.= ", '".$this->db->idate($now)."'";
$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_public)."'";
$sql.= ", ".$user->id.",";
@ -167,14 +167,14 @@ class FactureFournisseur extends CommonInvoice
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn');
// Update ref with new one
$this->ref='(PROV'.$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);
$resql=$this->db->query($sql);
if (! $resql) $error++;
// Update ref with new one
$this->ref='(PROV'.$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);
$resql=$this->db->query($sql);
if (! $resql) $error++;
// Add object linked
if (! $error && $this->id && ! empty($this->origin) && ! empty($this->origin_id))
@ -1350,8 +1350,8 @@ class FactureFournisseur extends CommonInvoice
global $db, $langs, $conf;
$langs->load("orders");
// 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';
// 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';
$mybool=false;
@ -1365,25 +1365,25 @@ class FactureFournisseur extends CommonInvoice
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
$obj = new $classname();
$numref = "";
$numref = $obj->getNumRef($soc,$this,$mode);
if ( $numref != "")
{
return $numref;
}
else
{
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
return false;
$obj = new $classname();
$numref = "";
$numref = $obj->getNumRef($soc,$this,$mode);
if ( $numref != "")
{
return $numref;
}
else
{
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
return false;
}
}

View File

@ -270,16 +270,18 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
{
$db->begin();
$tmpproject = GETPOST('projectid', 'int');
// Creation facture
$object->ref = $_POST['ref'];
$object->ref_supplier = $_POST['ref_supplier'];
$object->fk_project = GETPOST('projectid');
$object->socid = $_POST['socid'];
$object->libelle = $_POST['libelle'];
$object->date = $datefacture;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
// If creation from another object of another module
if ($_POST['origin'] && $_POST['originid'])