Fix: rename table

This commit is contained in:
Regis Houssin 2011-04-01 10:49:57 +00:00
parent 00605cb792
commit 49e120cfe2
6 changed files with 48 additions and 47 deletions

View File

@ -75,7 +75,7 @@ $tabname[17]= MAIN_DB_PREFIX."c_type_fees";
$tabname[18]= MAIN_DB_PREFIX."c_shipment_mode";
$tabname[19]= MAIN_DB_PREFIX."c_effectif";
$tabname[20]= MAIN_DB_PREFIX."c_methode_commande_fournisseur";
$tabname[21]= MAIN_DB_PREFIX."c_delivery";
$tabname[21]= MAIN_DB_PREFIX."c_availability";
// Dictionary labels
$tablib[1] = "DictionnaryCompanyJuridicalType";
@ -98,7 +98,7 @@ $tablib[17]= "DictionnaryFees";
$tablib[18]= "DictionnarySendingMethods";
$tablib[19]= "DictionnaryStaff";
$tablib[20]= "DictionnaryOrderMethods";
$tablib[21]= "DictionnaryDelivery";
$tablib[21]= "DictionnaryAvailability";
// Requete pour extraction des donnees des dictionnaires
$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as pays_code, p.libelle as pays, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid";
@ -121,7 +121,7 @@ $tabsql[17]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREF
$tabsql[18]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
$tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur";
$tabsql[21]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_delivery";
$tabsql[21]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability";
// Critere de tri du dictionnaire
$tabsqlsort[1] ="pays ASC, code ASC";
@ -144,7 +144,7 @@ $tabsqlsort[17]="code ASC";
$tabsqlsort[18]="code ASC, libelle ASC";
$tabsqlsort[19]="id ASC";
$tabsqlsort[20]="code ASC, libelle ASC";
$tabsqlsort[21]="code ASC, libelle ASC";
$tabsqlsort[21]="code ASC, label ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield[1] = "code,libelle,pays";
@ -167,7 +167,7 @@ $tabfield[17]= "code,libelle";
$tabfield[18]= "code,libelle";
$tabfield[19]= "code,libelle";
$tabfield[20]= "code,libelle";
$tabfield[21]= "code,libelle";
$tabfield[21]= "code,label";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue[1] = "code,libelle,pays";
@ -190,7 +190,7 @@ $tabfieldvalue[17]= "code,libelle";
$tabfieldvalue[18]= "code,libelle";
$tabfieldvalue[19]= "code,libelle";
$tabfieldvalue[20]= "code,libelle";
$tabfieldvalue[21]= "code,libelle";
$tabfieldvalue[21]= "code,label";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert[1] = "code,libelle,fk_pays";
@ -213,7 +213,7 @@ $tabfieldinsert[17]= "code,libelle";
$tabfieldinsert[18]= "code,libelle";
$tabfieldinsert[19]= "code,libelle";
$tabfieldinsert[20]= "code,libelle";
$tabfieldinsert[21]= "code,libelle";
$tabfieldinsert[21]= "code,label";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on

View File

@ -232,11 +232,11 @@ if ($_POST['action'] == 'setaddress' && $user->rights->propale->creer)
if ($result < 0) dol_print_error($db,$object->error);
}
//delai de livraison
if ($_POST['action'] == 'setdelivery' && $user->rights->propale->creer)
// Availability
if ($_POST['action'] == 'setavailability' && $user->rights->propale->creer)
{
$object->fetch($_GET["id"]);
$result=$object->set_delivery($user,$_POST['delivery']);
$result=$object->set_availability($user,$_POST['fk_availability']);
if ($result < 0) dol_print_error($db,$object->error);
}
@ -265,7 +265,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$object->ref = $_POST['ref'];
$object->datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$object->date_livraison = dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
$object->delivery = $_POST['delivery'];
$object->fk_availability = $_POST['fk_availability'];
$object->fk_delivery_address = $_POST['fk_address'];
$object->duree_validite = $_POST['duree_validite'];
$object->cond_reglement_id = $_POST['cond_reglement_id'];
@ -293,7 +293,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$object->ref_client = $_POST['ref_client'];
$object->datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$object->date_livraison = dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
$object->delivery = $_POST['delivery'];
$object->fk_availability = $_POST['fk_availability'];
$object->fk_delivery_address = $_POST['fk_address'];
$object->duree_validite = $_POST['duree_validite'];
$object->cond_reglement_id = $_POST['cond_reglement_id'];
@ -1271,21 +1271,21 @@ if ($id > 0 || ! empty($ref))
print '</td></tr>';
}
// Delivery
// Availability
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryPeriod');
print $langs->trans('AvailabilityPeriod');
print '</td>';
if ($_GET['action'] != 'editdelivery' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDelivery'),1).'</a></td>';
if ($_GET['action'] != 'editavailability' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editavailability&amp;id='.$object->id.'">'.img_edit($langs->trans('SetAvailability'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET['action'] == 'editdelivery')
if ($_GET['action'] == 'editavailability')
{
$html->form_delivery($_SERVER['PHP_SELF'].'?id='.$object->id,$object->delivery,'delivery');
$html->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_availability,'availability');
}
else
{
$html->form_delivery($_SERVER['PHP_SELF'].'?id='.$object->id,$object->delivery,'none');
$html->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_availability,'none');
}
print '</td>';
print '</tr>';

View File

@ -95,7 +95,7 @@ class Propal extends CommonObject
var $fk_address;
var $address_type;
var $adresse;
var $delivery;
var $fk_availability;
var $products=array();
@ -618,7 +618,7 @@ class Propal extends CommonObject
$sql.= ", fk_mode_reglement";
$sql.= ", ref_client";
$sql.= ", date_livraison";
$sql.= ", delivery";
$sql.= ", fk_availability";
$sql.= ", entity";
$sql.= ") ";
$sql.= " VALUES (";
@ -641,7 +641,7 @@ class Propal extends CommonObject
$sql.= ", ".$this->mode_reglement_id;
$sql.= ", '".$this->db->escape($this->ref_client)."'";
$sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":'null');
$sql.= ", ".$this->delivery;
$sql.= ", ".$this->fk_availability;
$sql.= ", ".$conf->entity;
$sql.= ")";
@ -904,7 +904,7 @@ class Propal extends CommonObject
$sql.= ", datep as dp";
$sql.= ", fin_validite as dfv";
$sql.= ", date_livraison as date_livraison";
$sql.= ", delivery";
$sql.= ", fk_availability";
$sql.= ", model_pdf, ref_client";
$sql.= ", note, note_public";
$sql.= ", fk_projet, fk_statut";
@ -958,7 +958,7 @@ class Propal extends CommonObject
$this->datep = $this->db->jdate($obj->dp);
$this->fin_validite = $this->db->jdate($obj->dfv);
$this->date_livraison = $this->db->jdate($obj->date_livraison);
$this->delivery = $obj->delivery;
$this->fk_availability = $obj->fk_availability;
$this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete
$this->fk_address = $obj->fk_adresse_livraison;
@ -1237,23 +1237,23 @@ class Propal extends CommonObject
* \param delivery delai de livraison
* \return int <0 si ko, >0 si ok
*/
function set_delivery($user, $delivery)
function set_availability($user, $id)
{
if ($user->rights->propale->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET delivery = '".$delivery."'";
$sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
$this->delivery = $delivery;
$this->fk_availability = $id;
return 1;
}
else
{
$this->error=$this->db->error();
dol_syslog("Propal::set_delivery Erreur SQL");
dol_syslog("Propal::set_availability Erreur SQL");
return -1;
}
}

View File

@ -1491,17 +1491,17 @@ class Form
* \brief Charge dans cache la liste des délais de livraison possibles
* \return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/
function load_cache_delivery()
function load_cache_availability()
{
global $langs;
if (sizeof($this->cache_delivery)) return 0; // Cache deja charge
if (sizeof($this->cache_availability)) return 0; // Cache deja charge
$sql = "SELECT rowid, code, libelle";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_delivery';
$sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_availability';
$sql.= " WHERE active=1";
$sql.= " ORDER BY rowid";
dol_syslog('Form::load_cache_delivery sql='.$sql,LOG_DEBUG);
dol_syslog('Form::load_cache_availability sql='.$sql,LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -1512,9 +1512,9 @@ class Form
$obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$libelle=($langs->trans("DeliveryType".$obj->code)!=("DeliveryType".$obj->code)?$langs->trans("DeliveryType".$obj->code):($obj->libelle!='-'?$obj->libelle:''));
$this->cache_delivery[$obj->rowid]['code'] =$obj->code;
$this->cache_delivery[$obj->rowid]['label']=$libelle;
$label=($langs->trans("AvailabilityType".$obj->code)!=("AvailabilityType".$obj->code)?$langs->trans("AvailabilityType".$obj->code):($obj->label!='-'?$obj->label:''));
$this->cache_availability[$obj->rowid]['code'] =$obj->code;
$this->cache_availability[$obj->rowid]['label']=$label;
$i++;
}
return 1;
@ -1532,15 +1532,15 @@ class Form
* \param filtertype Pour filtre
* \param addempty Ajoute entree vide
*/
function select_delivery($selected='',$htmlname='delivery',$filtertype='',$addempty=0)
function select_availability($selected='',$htmlname='availability',$filtertype='',$addempty=0)
{
global $langs,$user;
$this->load_cache_delivery();
$this->load_cache_availability();
print '<select class="flat" name="'.$htmlname.'">';
if ($addempty) print '<option value="0">&nbsp;</option>';
foreach($this->cache_delivery as $id => $arraydelivery)
foreach($this->cache_availability as $id => $arrayavailability)
{
if ($selected == $id)
{
@ -1550,7 +1550,7 @@ class Form
{
print '<option value="'.$id.'">';
}
print $arraydelivery['label'];
print $arrayavailability['label'];
print '</option>';
}
print '</select>';
@ -2136,17 +2136,17 @@ class Form
* \param htmlname Name of select html field
* \param addempty Ajoute entree vide
*/
function form_delivery($page, $selected='', $htmlname='delivery', $addempty=0)
function form_availability($page, $selected='', $htmlname='availability', $addempty=0)
{
global $langs;
if ($htmlname != "none")
{
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setdelivery">';
print '<input type="hidden" name="action" value="setavailability">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
print '<tr><td>';
$this->select_delivery($selected,$htmlname,-1,$addempty);
$this->select_availability($selected,$htmlname,-1,$addempty);
print '</td>';
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</tr></table></form>';
@ -2155,8 +2155,8 @@ class Form
{
if ($selected)
{
$this->load_cache_delivery();
print $this->cache_delivery[$selected]['label'];
$this->load_cache_availability();
print $this->cache_availability[$selected]['label'];
} else {
print "&nbsp;";
}

View File

@ -51,6 +51,7 @@ create table llx_c_availability
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
ALTER TABLE llx_propal ADD COLUMN fk_availability integer DEFAULT 0 AFTER fk_adresse_livraison;
ALTER TABLE llx_propal CHANGE COLUMN delivery fk_availability integer DEFAULT 0;
ALTER TABLE llx_availability CHANGE COLUMN libelle label integer varchar(60) NOT NULL;
ALTER TABLE llx_availability CHANGE COLUMN libelle label varchar(60) NOT NULL;

View File

@ -80,8 +80,8 @@ ClonePropal=Cloner proposition commerciale
ConfirmClonePropal=Êtes-vous sûr de vouloir cloner cette proposition commerciale <b>%s</b> ?
ProposalsAndProposalsLines=Propositions commerciales clientes et lignes de propositions
ProposalLine=Ligne de proposition
DeliveryPeriod=Délai de livraison (à réception de commande)
SetDelivery=Définir le délai de livraison
AvailabilityPeriod=Délai de livraison (à réception de commande)
SetAvailability=Définir le délai de livraison
##### Types de contacts #####
TypeContact_propal_internal_SALESREPFOLL=Commercial suivi propale
TypeContact_propal_external_BILLING=Contact client facturation propale