Qual: Début uniformisation code commandes fournisseurs avec commandes clients.
This commit is contained in:
parent
5ed51c4dfc
commit
6b0465c239
@ -69,8 +69,8 @@ if ($_GET["projetid"])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Categorisation dans projet
|
// Categorisation dans projet
|
||||||
if ($_POST['action'] == 'classin' && $user->rights->commande->creer)
|
if ($_POST['action'] == 'classin' && $user->rights->commande->creer)
|
||||||
@ -240,8 +240,8 @@ if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajout d'une ligne produit dans la commande
|
* Ajout d'une ligne produit dans la commande
|
||||||
*/
|
*/
|
||||||
if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
if ($_POST['qty'] && (($_POST['pu'] && $_POST['desc']) || $_POST['idprod']))
|
if ($_POST['qty'] && (($_POST['pu'] && $_POST['desc']) || $_POST['idprod']))
|
||||||
@ -315,8 +315,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mise à jour d'une ligne dans la propale
|
* Mise à jour d'une ligne dans la propale
|
||||||
*/
|
*/
|
||||||
if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
|
if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
|
||||||
{
|
{
|
||||||
$commande = new Commande($db,'',$_POST['id']);
|
$commande = new Commande($db,'',$_POST['id']);
|
||||||
@ -433,8 +433,8 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ordonnancement des lignes
|
* Ordonnancement des lignes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_GET['action'] == 'up' && $user->rights->commande->creer)
|
if ($_GET['action'] == 'up' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
@ -448,6 +448,7 @@ if ($_GET['action'] == 'up' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']);
|
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET['action'] == 'down' && $user->rights->commande->creer)
|
if ($_GET['action'] == 'down' && $user->rights->commande->creer)
|
||||||
@ -462,6 +463,7 @@ if ($_GET['action'] == 'down' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
commande_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs);
|
||||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']);
|
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||||
@ -493,6 +495,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#builddoc');
|
Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$commande->id.'#builddoc');
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,8 +514,8 @@ if ($action=='remove_file')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Envoi de la commande par mail
|
* Envoi de la commande par mail
|
||||||
*/
|
*/
|
||||||
if ($_POST['action'] == 'send')
|
if ($_POST['action'] == 'send')
|
||||||
{
|
{
|
||||||
$langs->load('mails');
|
$langs->load('mails');
|
||||||
@ -672,10 +675,10 @@ llxHeader('',$langs->trans('Order'),'Commande');
|
|||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
*
|
*
|
||||||
* Mode creation
|
* Mode creation
|
||||||
*
|
*
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
||||||
{
|
{
|
||||||
print_titre($langs->trans('CreateOrder'));
|
print_titre($langs->trans('CreateOrder'));
|
||||||
@ -1100,7 +1103,7 @@ else
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
// Société
|
// Sociét
|
||||||
print '<tr><td>'.$langs->trans('Company').'</td>';
|
print '<tr><td>'.$langs->trans('Company').'</td>';
|
||||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -49,7 +49,7 @@ if ($_GET["id"] > 0)
|
|||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
|
|
||||||
if ( $commande->fetch($_GET["id"]) == 0)
|
if ( $commande->fetch($_GET["id"]) >= 0)
|
||||||
{
|
{
|
||||||
$soc->fetch($commande->socid);
|
$soc->fetch($commande->socid);
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ $html = new Form($db);
|
|||||||
if ($_GET["id"] > 0)
|
if ($_GET["id"] > 0)
|
||||||
{
|
{
|
||||||
$commande = new CommandeFournisseur($db);
|
$commande = new CommandeFournisseur($db);
|
||||||
if ( $commande->fetch($_GET["id"]) == 0)
|
if ( $commande->fetch($_GET["id"]) >= 0)
|
||||||
{
|
{
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->socid);
|
$soc->fetch($commande->socid);
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class CommandeFournisseur extends Commande
|
|||||||
/**
|
/**
|
||||||
* Lit une commande
|
* Lit une commande
|
||||||
*/
|
*/
|
||||||
function fetch ($id)
|
function fetch($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,";
|
$sql = "SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,";
|
||||||
$sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande,";
|
$sql .= " ".$this->db->pdate("c.date_commande")." as date_commande, c.fk_projet, c.remise_percent, c.source, c.fk_methode_commande,";
|
||||||
@ -75,10 +75,10 @@ class CommandeFournisseur extends Commande
|
|||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_methode_commande_fournisseur as cm ON cm.rowid = c.fk_methode_commande";
|
||||||
$sql .= " WHERE c.rowid = ".$id;
|
$sql .= " WHERE c.rowid = ".$id;
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$resql = $this->db->query($sql) ;
|
||||||
if ($result)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->ref = $obj->ref;
|
$this->ref = $obj->ref;
|
||||||
@ -105,7 +105,7 @@ class CommandeFournisseur extends Commande
|
|||||||
|
|
||||||
if ($this->statut == 0) $this->brouillon = 1;
|
if ($this->statut == 0) $this->brouillon = 1;
|
||||||
|
|
||||||
// export pdf -----------
|
// export pdf -----------
|
||||||
|
|
||||||
$this->lignes = array();
|
$this->lignes = array();
|
||||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
|
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,';
|
||||||
@ -145,15 +145,22 @@ class CommandeFournisseur extends Commande
|
|||||||
}
|
}
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_syslog("CommandeFournisseur::Fetch Error $sql");
|
$this->error=$this->db->error()." sql=".$sql;
|
||||||
dolibarr_syslog("CommandeFournisseur::Fetch Error ".$this->db->error());
|
dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error()." sql=".$sql;
|
||||||
|
dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Insère ligne de log
|
* \brief Insère ligne de log
|
||||||
@ -621,7 +628,7 @@ class CommandeFournisseur extends Commande
|
|||||||
$desc = trim($desc);
|
$desc = trim($desc);
|
||||||
$remise_percent = price2num($remise_percent);
|
$remise_percent = price2num($remise_percent);
|
||||||
|
|
||||||
dolibarr_syslog("Fournisseur_Commande.class.php::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
|
dolibarr_syslog("Fournisseur.Commande.class::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
|
||||||
|
|
||||||
if ($qty < 1 && ! $fk_product)
|
if ($qty < 1 && ! $fk_product)
|
||||||
{
|
{
|
||||||
@ -639,7 +646,7 @@ class CommandeFournisseur extends Commande
|
|||||||
if ($prod->fetch($fk_product) > 0)
|
if ($prod->fetch($fk_product) > 0)
|
||||||
{
|
{
|
||||||
$result=$prod->get_buyprice($this->fourn_id,$qty);
|
$result=$prod->get_buyprice($this->fourn_id,$qty);
|
||||||
if ($result)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$label = $prod->libelle;
|
$label = $prod->libelle;
|
||||||
$desc = $prod->description;
|
$desc = $prod->description;
|
||||||
@ -647,13 +654,25 @@ class CommandeFournisseur extends Commande
|
|||||||
$pu = $prod->fourn_pu;
|
$pu = $prod->fourn_pu;
|
||||||
$ref = $prod->ref;
|
$ref = $prod->ref;
|
||||||
}
|
}
|
||||||
else
|
if ($result == 0 || $result == -1)
|
||||||
{
|
{
|
||||||
$this->error="Aucun tarif trouvé pour cette quantité. Quantité saisie insuffisante ?";
|
$this->error="Aucun tarif trouvé pour cette quantité. Quantité saisie insuffisante ?";
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
dolibarr_syslog($this->error);
|
dolibarr_syslog("Fournisseur.commande.class::addline result=".$result." - ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if ($result < -1)
|
||||||
|
{
|
||||||
|
$this->error=$prod->error;
|
||||||
|
$this->db->rollback();
|
||||||
|
dolibarr_syslog("Fournisseur.commande.class::addline result=".$result." - ".$this->error);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,7 +687,9 @@ class CommandeFournisseur extends Commande
|
|||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)";
|
||||||
$sql .= " VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_product.",".price2num($price).", '$qty', $txtva, $remise_percent,'".price2num($subprice)."','".price2num($remise)."','".$ref."') ;";
|
$sql .= " VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_product.",".price2num($price).", '$qty', $txtva, $remise_percent,'".price2num($subprice)."','".price2num($remise)."','".$ref."') ;";
|
||||||
if ( $this->db->query( $sql) )
|
dolibarr_syslog('Fournisseur.commande.class::addline sql='.$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
@ -692,19 +713,26 @@ class CommandeFournisseur extends Commande
|
|||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idligne;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid = ".$idligne;
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
dolibarr_syslog("Fournisseur.commande.class::delete_line sql=".$sql);
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$result=$this->update_price();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Mettre à jour le prix
|
* Mettre à jour le prix
|
||||||
*
|
*
|
||||||
@ -1150,6 +1178,7 @@ class CommandeFournisseur extends Commande
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
|
dolibarr_syslog("Commande.fournisseur.class::updateline ".$this->error);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1157,6 +1186,7 @@ class CommandeFournisseur extends Commande
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error="Commande::updateline Order status makes operation forbidden";
|
$this->error="Commande::updateline Order status makes operation forbidden";
|
||||||
|
dolibarr_syslog("Commande.fournisseur.class::updateline ".$this->error);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -614,12 +614,14 @@ class Product
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user