to add delivery date

This commit is contained in:
Grand Philippe 2012-04-10 17:21:28 +02:00
parent 06761d9753
commit c8dd3b4801
4 changed files with 168 additions and 92 deletions

View File

@ -54,6 +54,7 @@ class CommandeFournisseur extends Commande
var $fourn_id; var $fourn_id;
var $date; var $date;
var $date_commande; var $date_commande;
var $date_livraison; // Date livraison souhaitee
var $total_ht; var $total_ht;
var $total_tva; var $total_tva;
var $total_localtax1; // Total Local tax 1 var $total_localtax1; // Total Local tax 1
@ -1367,6 +1368,41 @@ class CommandeFournisseur extends Commande
return $result ; return $result ;
} }
/**
* Set the planned delivery date
*
* @param User $user Objet utilisateur qui modifie
* @param timestamp $date_livraison Date de livraison
* @return int <0 si ko, >0 si ok
*/
function set_date_livraison($user, $date_livraison)
{
if ($user->rights->fournisseur->commande->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("CommandeFournisseur::set_date_livraison sql=".$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->date_livraison = $date_livraison;
return 1;
}
else
{
$this->error=$this->db->error();
dol_syslog("CommandeFournisseur::set_date_livraison ".$this->error,LOG_ERR);
return -1;
}
}
else
{
return -2;
}
}
/** /**
* Update a supplier order from a customer order * Update a supplier order from a customer order
* *

View File

@ -48,12 +48,12 @@ $langs->load('products');
$langs->load('stocks'); $langs->load('stocks');
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST("ref"); $ref = GETPOST('ref','alpha');
$action = GETPOST("action"); $action = GETPOST('action','alpha');
$confirm = GETPOST("confirm"); $confirm = GETPOST('confirm','alpha');
$comclientid = GETPOST("comid"); $comclientid = GETPOST('comid','int');
$socid = GETPOST('socid','int'); $socid = GETPOST('socid','int');
$projectid = GETPOST("projectid"); $projectid = GETPOST('projectid','int');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@ -87,6 +87,19 @@ else if ($action == 'setmode' && $user->rights->fournisseur->commande->creer)
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int'));
} }
// date de livraison
if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer)
{
$datelivraison=dol_mktime(0, 0, 0, GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
$object->fetch($id);
$result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0)
{
$mesg='<div class="error">'.$object->error.'</div>';
}
}
// Set project // Set project
else if ($action == 'classin' && $user->rights->fournisseur->commande->creer) else if ($action == 'classin' && $user->rights->fournisseur->commande->creer)
{ {
@ -1102,6 +1115,30 @@ if ($id > 0 || ! empty($ref))
} }
print '</td></tr>'; print '</td></tr>';
// Delivery date planed
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateDeliveryPlanned');
print '</td>';
if ($action != 'editdate_livraison') print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($action == 'editdate_livraison')
{
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setdate_livraison">';
$form->select_date($object->date_livraison?$object->date_livraison:-1,'liv_','','','',"setdate_livraison");
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $object->date_livraison ? dol_print_date($object->date_livraison,'daytext') : '&nbsp;';
}
print '</td>';
// Project // Project
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {

View File

@ -451,3 +451,5 @@ ALTER TABLE llx_commande_fournisseur ADD COLUMN extraparams varchar(255) AFTER i
ALTER TABLE llx_facture_fourn ADD COLUMN extraparams varchar(255) AFTER import_key; ALTER TABLE llx_facture_fourn ADD COLUMN extraparams varchar(255) AFTER import_key;
ALTER TABLE llx_boxes ADD COLUMN maxline integer NULL; ALTER TABLE llx_boxes ADD COLUMN maxline integer NULL;
ALTER TABLE llx_commande_fournisseur ADD COLUMN date_livraison date NULL;

View File

@ -54,6 +54,7 @@ create table llx_commande_fournisseur
note_public text, note_public text,
model_pdf varchar(255), model_pdf varchar(255),
date_livraison date default NULL,
fk_cond_reglement integer, -- condition de reglement fk_cond_reglement integer, -- condition de reglement
fk_mode_reglement integer, -- mode de reglement fk_mode_reglement integer, -- mode de reglement
fk_methode_commande integer default 0, -- should be named fk_input_method fk_methode_commande integer default 0, -- should be named fk_input_method