Dbut ajout de la gestion des adresses de livraison
This commit is contained in:
parent
00b300c6ee
commit
826308b9e2
@ -279,13 +279,14 @@ class Commande
|
||||
}
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (';
|
||||
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison) ';
|
||||
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison) ';
|
||||
$sql.= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.',';
|
||||
$sql.= ' '.$this->db->idate($this->date_commande).',';
|
||||
$sql.= ' '.$this->source.', ';
|
||||
$sql.= " '".addslashes($this->note)."', ";
|
||||
$sql.= " '".$this->ref_client."', '".$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\',';
|
||||
$sql.= " ".($this->date_livraison?$this->db->idate($this->date_livraison):'null').")";
|
||||
$sql.= " '".($this->date_livraison?$this->db->idate($this->date_livraison):'null').'\',';
|
||||
$sql.= " '".$this->adresse_reglement_id."')";
|
||||
|
||||
dolibarr_syslog("Commande.class.php::create sql=$sql");
|
||||
if ( $this->db->query($sql) )
|
||||
@ -606,7 +607,7 @@ class Commande
|
||||
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, c.fk_cond_reglement, c.fk_mode_reglement';
|
||||
$sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.date_livraison';
|
||||
$sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.date_livraison, c.fk_adresse_livraison';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c';
|
||||
$sql .= ' WHERE c.rowid = '.$id;
|
||||
|
||||
@ -614,25 +615,26 @@ class Commande
|
||||
if ( $result )
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->soc_id = $obj->fk_soc;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->total_ht = $obj->total_ht;
|
||||
$this->total_tva = $obj->tva;
|
||||
$this->total_ttc = $obj->total_ttc;
|
||||
$this->date = $obj->date_commande;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
$this->source = $obj->source;
|
||||
$this->facturee = $obj->facture;
|
||||
$this->note = $obj->note;
|
||||
$this->projet_id = $obj->fk_projet;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
$this->soc_id = $obj->fk_soc;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
$this->total_ht = $obj->total_ht;
|
||||
$this->total_tva = $obj->tva;
|
||||
$this->total_ttc = $obj->total_ttc;
|
||||
$this->date = $obj->date_commande;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
$this->source = $obj->source;
|
||||
$this->facturee = $obj->facture;
|
||||
$this->note = $obj->note;
|
||||
$this->projet_id = $obj->fk_projet;
|
||||
$this->modelpdf = $obj->model_pdf;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
||||
|
||||
$this->db->free();
|
||||
if ($this->statut == 0)
|
||||
|
||||
@ -687,7 +687,7 @@ else
|
||||
print $langs->trans('DateDelivery');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
|
||||
if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$commande->id.'">'.img_edit($langs->trans('SetDateDelivery'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'editdate_livraison')
|
||||
@ -702,6 +702,25 @@ else
|
||||
{
|
||||
print dolibarr_print_date($commande->date_livraison,'%a %d %B %Y');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// adresse de livraison
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DeliveryAdress');
|
||||
print '</td>';
|
||||
|
||||
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAdress'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($_GET['action'] == 'editdelivery_adress')
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,'adresse_livraison_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,'none');
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Conditions et modes de réglement
|
||||
|
||||
@ -756,6 +756,48 @@ class Form
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste déroulante des adresses de livraison
|
||||
* \param selected Id contact pré-sélectionn
|
||||
* \param htmlname Nom champ formulaire
|
||||
*/
|
||||
function select_adresse_livraison($selected='', $socid, $htmlname='idl')
|
||||
{
|
||||
// On recherche les utilisateurs
|
||||
$sql = "SELECT a.rowid, a.label";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX ."societe_adresse_livraison as a";
|
||||
$sql .= " WHERE a.fk_societe = ".$socid;
|
||||
$sql .= " ORDER BY a.label ASC";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
if ($selected && $selected == $obj->rowid)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->label.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">'.$obj->label.'</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge dans cache la liste des conditions de paiements possibles
|
||||
@ -1535,7 +1577,43 @@ class Form
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Affiche formulaire de selection de l'adresse de livraison
|
||||
* \param page Page
|
||||
* \param selected Id condition présélectionnée
|
||||
* \param htmlname Nom du formulaire select
|
||||
* \param addempty Ajoute entrée vide
|
||||
*/
|
||||
function form_adresse_livraison($page, $selected='', $socid, $htmlname='adresse_livraison_id')
|
||||
{
|
||||
global $langs;
|
||||
if ($htmlname != "none")
|
||||
{
|
||||
print '<form method="post" action="'.$page.'">';
|
||||
print '<input type="hidden" name="action" value="setdeliveryadress">';
|
||||
print '<table class="noborder" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
$this->select_adresse_livraison($selected, $socid, $htmlname);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print '</tr></table></form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($selected)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT ."/comm/adresse_livraison.class.php");
|
||||
$livraison=new Livraison($this->db);
|
||||
$livraison->fetch_adresse($selected);
|
||||
print $livraison->label;
|
||||
}
|
||||
else
|
||||
{
|
||||
print " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste des devises, dans la langue de l'utilisateur
|
||||
|
||||
Loading…
Reference in New Issue
Block a user