Début modification expedition livraison

Phase2: modification des livraisons
- elles pourront désormais etre lié à une propale (pas encore effectif)
- on pourra faire un bon de livraison sans document de base
This commit is contained in:
Regis Houssin 2008-01-31 14:23:57 +00:00
parent 79599aaf67
commit 9dbcea96b9
2 changed files with 318 additions and 299 deletions

View File

@ -364,12 +364,8 @@ else
if ( $livraison->id > 0) if ( $livraison->id > 0)
{ {
$commande = New Commande($db);
$commande->fetch($livraison->commande_id);
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($commande->socid); $soc->fetch($livraison->socid);
$h=0; $h=0;
if ($conf->expedition_bon->enabled) if ($conf->expedition_bon->enabled)
@ -409,13 +405,8 @@ else
/* /*
* Commande * Livraison
*/ */
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$livraison->id.'" method="post">';
}
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
@ -427,14 +418,14 @@ else
print '<td align="3">'.$soc->getNomUrl(1).'</td>'; print '<td align="3">'.$soc->getNomUrl(1).'</td>';
print "</tr>"; print "</tr>";
// Commande liée // Document origine
print '<tr><td>'.$langs->trans("RefOrder").'</td>'; print '<tr><td>'.$langs->trans("RefOrder").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref."</a></td>\n"; print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref."</a></td>\n";
print '</tr>'; print '</tr>';
// Commande liée // Commande liée
print '<tr><td>'.$langs->trans("RefCustomerOrderShort").'</td>'; print '<tr><td>'.$langs->trans("RefCustomerOrderShort").'</td>';
print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref_client."</a></td>\n"; print '<td colspan="3">'.$livraison->ref_client."</a></td>\n";
print '</tr>'; print '</tr>';
// Date // Date
@ -495,6 +486,7 @@ else
{ {
print "<td>".$livraison->lignes[$i]->description."</td>\n"; print "<td>".$livraison->lignes[$i]->description."</td>\n";
} }
print '<td align="center">'.$livraison->lignes[$i]->qty_asked.'</td>'; print '<td align="center">'.$livraison->lignes[$i]->qty_asked.'</td>';
print '<td align="center">'.$livraison->lignes[$i]->qty_delivered.'</td>'; print '<td align="center">'.$livraison->lignes[$i]->qty_delivered.'</td>';
@ -553,22 +545,20 @@ else
$genallowed=$user->rights->expedition->livraison->creer; $genallowed=$user->rights->expedition->livraison->creer;
$delallowed=$user->rights->expedition->livraison->supprimer; $delallowed=$user->rights->expedition->livraison->supprimer;
//$genallowed=1;
//$delallowed=0;
$somethingshown=$formfile->show_documents('livraison',$livraisonref,$filedir,$urlsource,$genallowed,$delallowed,$livraison->modelpdf); $somethingshown=$formfile->show_documents('livraison',$livraisonref,$filedir,$urlsource,$genallowed,$delallowed,$livraison->modelpdf);
/* /*
* Déjà livre * Déjà livre
*/ */
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande"; $sql = "SELECT ld.fk_product, ld.description, ld.qty as qty_livre, ld.fk_livraison as livraison_id";
$sql .= " , ld.qty as qty_livre, l.ref, ld.fk_livraison as livraison_id"; $sql.= ", l.ref, ".$db->pdate("l.date_livraison")." as date_livraison";
$sql .= ",".$db->pdate("l.date_livraison")." as date_livraison"; $sql.= ", cd.rowid, cd.qty as qty_commande";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " , ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l"; $sql.= " , ".MAIN_DB_PREFIX."livraisondet as ld, ".MAIN_DB_PREFIX."livraison as l";
$sql.= " WHERE cd.fk_commande = ".$livraison->commande_id; $sql.= " WHERE cd.fk_commande = ".$livraison->commande_id;
$sql.= " AND l.rowid <> ".$livraison->id; $sql.= " AND l.rowid <> ".$livraison->id;
$sql .= " AND cd.rowid = ld.fk_commande_ligne"; $sql.= " AND cd.rowid = ld.fk_origin_line";
$sql.= " AND ld.fk_livraison = l.rowid"; $sql.= " AND ld.fk_livraison = l.rowid";
$sql.= " AND l.fk_statut > 0"; $sql.= " AND l.fk_statut > 0";
$sql.= " ORDER BY cd.fk_product"; $sql.= " ORDER BY cd.fk_product";
@ -623,17 +613,16 @@ else
} }
$db->free($resql); $db->free($resql);
} }
else { else
{
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
// Rien à droite // Rien à droite
print '</td></tr></table>'; print '</td></tr></table>';
} }
else else
{ {

View File

@ -235,6 +235,8 @@ class Livraison extends CommonObject
$result = $this->db->query($sql) ; $result = $this->db->query($sql) ;
if ($result) if ($result)
{
if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
@ -254,19 +256,47 @@ class Livraison extends CommonObject
$this->note = $obj->note; $this->note = $obj->note;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->db->free();
$this->db->free($result);
if ($this->origin_id)
{
if ($conf->commande->enabled)
{
$this->origin = "commande";
}
else
{
$this->origin = "propal";
}
}
if ($this->statut == 0) $this->brouillon = 1; if ($this->statut == 0) $this->brouillon = 1;
$file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id,2) . "/" . $this->id.".pdf"; $file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id,2) . "/" . $this->id.".pdf";
$this->pdf_filename = $file; $this->pdf_filename = $file;
$this->fetch_lignes(); /*
* Lignes
*/
$result=$this->fetch_lignes();
if ($result < 0)
{
return -3;
}
return 1; return 1;
} }
else else
{ {
$this->error='Delivery with id '.$rowid.' not found sql='.$sql;
dolibarr_syslog('Livraison::Fetch Error '.$this->error);
return -2;
}
}
else
{
dolibarr_syslog('Livraison::Fetch Error '.$this->error);
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }