Fix a lot of bug in "source" field:

- missing creation table
- autoselect when creating order from proposal
- do not show proposal as origin when creating proposal
- use code instead of id
- use label in english
Also renamed table demand_reason into input_reason to match other table input_method.
This commit is contained in:
Laurent Destailleur
2011-05-07 11:36:47 +00:00
parent f4ed30f2dd
commit ff6182f62f
10 changed files with 137 additions and 84 deletions

View File

@@ -77,7 +77,7 @@ $tabname[18]= MAIN_DB_PREFIX."c_shipment_mode";
$tabname[19]= MAIN_DB_PREFIX."c_effectif"; $tabname[19]= MAIN_DB_PREFIX."c_effectif";
$tabname[20]= MAIN_DB_PREFIX."c_input_method"; $tabname[20]= MAIN_DB_PREFIX."c_input_method";
$tabname[21]= MAIN_DB_PREFIX."c_availability"; $tabname[21]= MAIN_DB_PREFIX."c_availability";
$tabname[22]= MAIN_DB_PREFIX."c_demand_reason"; $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
// Dictionary labels // Dictionary labels
$tablib[1] = "DictionnaryCompanyJuridicalType"; $tablib[1] = "DictionnaryCompanyJuridicalType";
@@ -125,7 +125,7 @@ $tabsql[18]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREF
$tabsql[19]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; $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_input_method"; $tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
$tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_demand_reason"; $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
// Critere de tri du dictionnaire // Critere de tri du dictionnaire
$tabsqlsort[1] ="pays ASC, code ASC"; $tabsqlsort[1] ="pays ASC, code ASC";

View File

@@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
@@ -43,6 +43,13 @@ $langs->load("bills");
$langs->load("orders"); $langs->load("orders");
$langs->load("deliveries"); $langs->load("deliveries");
/*
* Actions
*/
// None
/* /*
* View * View
@@ -55,9 +62,7 @@ print_fiche_titre($langs->trans("NewProp"));
$html=new Form($db); $html=new Form($db);
/* // Add new proposal
* Creation d'une nouvelle propale
*/
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
$soc = new Societe($db); $soc = new Societe($db);
@@ -127,9 +132,7 @@ if ($_GET["action"] == 'create')
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
/* // Contacts
* Contact de la propale
*/
print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n"; print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n";
$html->select_contacts($soc->id,$setcontact,'contactidp',1); $html->select_contacts($soc->id,$setcontact,'contactidp',1);
print '</td></tr>'; print '</td></tr>';
@@ -161,15 +164,15 @@ if ($_GET["action"] == 'create')
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
$html->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); $html->select_types_paiements($soc->mode_reglement,'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Source de propale // What trigger creation
print '<tr><td>'.$langs->trans('Source').'</td><td>'; print '<tr><td>'.$langs->trans('Source').'</td><td>';
$html->select_demand_reason($soc->demand_reason,'demand_reason_id'); $html->select_demand_reason($propal->demand_reason,'demand_reason_id',"SRC_PROP",1);
print '</td></tr>'; print '</td></tr>';
// delai de livraison // delai de livraison
print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td colspan="2">';
$html->select_availability($soc->availability,'availability_id'); $html->select_availability($propal->availability,'availability_id');
print '</td></tr>'; print '</td></tr>';
// Delivery date (or manufacturing) // Delivery date (or manufacturing)

View File

@@ -1321,9 +1321,10 @@ if ($id > 0 || ! empty($ref))
if ($action != 'editdemandreason' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDemandReason'),1).'</a></td>'; if ($action != 'editdemandreason' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDemandReason'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
//print $object->demand_reason_id;
if ($action == 'editdemandreason') if ($action == 'editdemandreason')
{ {
$html->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id'); $html->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1);
} }
else else
{ {

View File

@@ -405,7 +405,7 @@ class Propal extends CommonObject
{ {
// Reorder if child line // Reorder if child line
if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la propale meme // Mise a jour informations denormalisees au niveau de la propale meme
$result=$this->update_price(1); $result=$this->update_price(1);
if ($result > 0) if ($result > 0)
@@ -482,15 +482,15 @@ class Propal extends CommonObject
$remise = round(($pu * $remise_percent / 100), 2); $remise = round(($pu * $remise_percent / 100), 2);
$price = $pu - $remise; $price = $pu - $remise;
} }
// Update line // Update line
$this->line=new PropaleLigne($this->db); $this->line=new PropaleLigne($this->db);
// Stock previous line records // Stock previous line records
$staticline=new PropaleLigne($this->db); $staticline=new PropaleLigne($this->db);
$staticline->fetch($rowid); $staticline->fetch($rowid);
$this->line->oldline = $staticline; $this->line->oldline = $staticline;
$this->line->rowid=$rowid; $this->line->rowid=$rowid;
$this->line->desc=$desc; $this->line->desc=$desc;
$this->line->qty=$qty; $this->line->qty=$qty;
@@ -508,13 +508,13 @@ class Propal extends CommonObject
$this->line->special_code=$special_code; $this->line->special_code=$special_code;
$this->line->fk_parent_line=$fk_parent_line; $this->line->fk_parent_line=$fk_parent_line;
$this->line->skip_update_total=$skip_update_total; $this->line->skip_update_total=$skip_update_total;
if (empty($qty) && empty($special_code)) $this->line->special_code=3; if (empty($qty) && empty($special_code)) $this->line->special_code=3;
// TODO deprecated // TODO deprecated
$this->line->price=$price; $this->line->price=$price;
$this->line->remise=$remise; $this->line->remise=$remise;
$result=$this->line->update(); $result=$this->line->update();
if ($result > 0) if ($result > 0)
{ {
@@ -552,7 +552,7 @@ class Propal extends CommonObject
if ($this->statut == 0) if ($this->statut == 0)
{ {
$line=new PropaleLigne($this->db); $line=new PropaleLigne($this->db);
// For triggers // For triggers
$line->fetch($lineid); $line->fetch($lineid);
@@ -685,14 +685,14 @@ class Propal extends CommonObject
{ {
$fk_parent_line=0; $fk_parent_line=0;
$num=sizeof($this->lines); $num=sizeof($this->lines);
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
// Reset fk_parent_line for no child products and special product // Reset fk_parent_line for no child products and special product
if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) { if (($this->lines[$i]->product_type != 9 && empty($this->lines[$i]->fk_parent_line)) || $this->lines[$i]->product_type == 9) {
$fk_parent_line = 0; $fk_parent_line = 0;
} }
$result = $this->addline( $result = $this->addline(
$this->id, $this->id,
$this->lines[$i]->desc, $this->lines[$i]->desc,
@@ -846,9 +846,9 @@ class Propal extends CommonObject
// Load source object // Load source object
$object->fetch($fromid); $object->fetch($fromid);
$objFrom = $object; $objFrom = $object;
$objsoc=new Societe($this->db); $objsoc=new Societe($this->db);
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $object->socid) if (! empty($socid) && $socid != $object->socid)
{ {
@@ -860,7 +860,7 @@ class Propal extends CommonObject
$object->fk_project = ''; $object->fk_project = '';
$object->fk_delivery_address = ''; $object->fk_delivery_address = '';
} }
// TODO Change product price if multi-prices // TODO Change product price if multi-prices
} }
else else
@@ -971,7 +971,7 @@ class Propal extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_demand_reason as dr ON p.fk_demand_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_demand_reason = dr.rowid';
$sql.= " WHERE p.fk_statut = c.id"; $sql.= " WHERE p.fk_statut = c.id";
$sql.= " AND p.entity = ".$conf->entity; $sql.= " AND p.entity = ".$conf->entity;
if ($ref) $sql.= " AND p.ref='".$ref."'"; if ($ref) $sql.= " AND p.ref='".$ref."'";
@@ -1346,7 +1346,7 @@ class Propal extends CommonObject
} }
} }
} }
/** /**
* \brief Positionne numero reference client * \brief Positionne numero reference client
* \param user Utilisateur qui modifie * \param user Utilisateur qui modifie
@@ -1900,7 +1900,7 @@ class Propal extends CommonObject
return -2; return -2;
} }
} }
/** /**
* \brief Change l'origine de la demande * \brief Change l'origine de la demande
* \param demand_reason_id Id de la nouvelle origine de demande * \param demand_reason_id Id de la nouvelle origine de demande
@@ -2379,7 +2379,7 @@ class PropaleLigne
{ {
var $db; var $db;
var $error; var $error;
var $oldline; var $oldline;
// From llx_propaldet // From llx_propaldet
@@ -2421,12 +2421,12 @@ class PropaleLigne
var $ref; // Reference produit var $ref; // Reference produit
var $libelle; // Label produit var $libelle; // Label produit
var $product_desc; // Description produit var $product_desc; // Description produit
var $localtax1_tx; var $localtax1_tx;
var $localtax2_tx; var $localtax2_tx;
var $total_localtax1; var $total_localtax1;
var $total_localtax2; var $total_localtax2;
var $skip_update_total; // Skip update price total for special lines var $skip_update_total; // Skip update price total for special lines
/** /**
@@ -2579,7 +2579,7 @@ class PropaleLigne
return -1; return -1;
} }
} }
/** /**
* Delete line in database * Delete line in database
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
@@ -2587,9 +2587,9 @@ class PropaleLigne
function delete() function delete()
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid;
dol_syslog("PropaleLigne::delete sql=".$sql, LOG_DEBUG); dol_syslog("PropaleLigne::delete sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql) ) if ($this->db->query($sql) )
@@ -2600,9 +2600,9 @@ class PropaleLigne
$result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); $result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
@@ -2613,7 +2613,7 @@ class PropaleLigne
return -1; return -1;
} }
} }
/** /**
* \brief Mise a jour de l'objet ligne de propale en base * \brief Mise a jour de l'objet ligne de propale en base
* \return int <0 si ko, >0 si ok * \return int <0 si ko, >0 si ok
@@ -2621,7 +2621,7 @@ class PropaleLigne
function update($notrigger=0) function update($notrigger=0)
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
// Clean parameters // Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
@@ -2635,7 +2635,7 @@ class PropaleLigne
if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->special_code)) $this->special_code=0; if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
$this->db->begin(); $this->db->begin();
// Mise a jour ligne en base // Mise a jour ligne en base
@@ -2677,7 +2677,7 @@ class PropaleLigne
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
} }
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@@ -1180,7 +1180,7 @@ class Commande extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_demand_reason as dr ON (c.fk_demand_reason = ca.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_demand_reason = ca.rowid)';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = c.rowid AND el.targettype = '".$this->element."'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = c.rowid AND el.targettype = '".$this->element."'";
$sql.= " WHERE c.entity = ".$conf->entity; $sql.= " WHERE c.entity = ".$conf->entity;
if ($ref) $sql.= " AND c.ref='".$ref."'"; if ($ref) $sql.= " AND c.ref='".$ref."'";

View File

@@ -1274,15 +1274,15 @@ if ($action == 'create' && $user->rights->commande->creer)
// delai de livraison // delai de livraison
print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td>'; print '<tr><td>'.$langs->trans('AvailabilityPeriod').'</td><td>';
$html->select_availability($soc->availability,'availability_id'); $html->select_availability($propal->availability,'availability_id');
print '</td></tr>'; print '</td></tr>';
// Source de commande // What trigger creation
print '<tr><td>'.$langs->trans('Source').'</td><td>'; print '<tr><td>'.$langs->trans('Source').'</td><td>';
$html->select_demand_reason($soc->demand_reason,'demand_reason_id'); $html->select_demand_reason((GETPOST("origin")=='propal'?'SRC_COMM':''),'demand_reason_id','',1);
print '</td></tr>'; print '</td></tr>';
// Projet // Project
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
$projectid = 0; $projectid = 0;
@@ -1297,10 +1297,6 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td></tr>'; print '</td></tr>';
} }
print '<tr><td>'.$langs->trans('Source').'</td><td colspan="2">';
$formorder->selectSourcesCommande((GETPOST("origin")=='propal'?'0':''),'source_id',1);
print '</td></tr>';
print '<tr><td>'.$langs->trans('Model').'</td>'; print '<tr><td>'.$langs->trans('Model').'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
// pdf // pdf
@@ -1770,7 +1766,7 @@ else
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($_GET['action'] == 'editdemandreason') if ($_GET['action'] == 'editdemandreason')
{ {
$html->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id'); $html->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1);
} }
else else
{ {

View File

@@ -1535,17 +1535,17 @@ class Form
} }
/** /**
* \brief Charge dans cache la liste des origines de commande possibles * Load into cache cache_demand_reason, array of input reasons
* \return int Nb lignes chargees, 0 si deja chargees, <0 si ko * @return int Nb of lines loaded, 0 if already loaded, <0 if ko
*/ */
function load_cache_demand_reason() function load_cache_demand_reason()
{ {
global $langs; global $langs;
if (sizeof($this->cache_demand_reason)) return 0; // Cache deja charge if (sizeof($this->cache_demand_reason)) return 0; // Cache already loaded
$sql = "SELECT rowid, code, label"; $sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX.'c_demand_reason'; $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_reason';
$sql.= " WHERE active=1"; $sql.= " WHERE active=1";
$sql.= " ORDER BY rowid"; $sql.= " ORDER BY rowid";
dol_syslog('Form::load_cache_demand_reason sql='.$sql,LOG_DEBUG); dol_syslog('Form::load_cache_demand_reason sql='.$sql,LOG_DEBUG);
@@ -1554,16 +1554,21 @@ class Form
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
$tmparray=array();
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$label=($langs->trans("DemandReasonType".$obj->code)!=("DemandReasonType".$obj->code)?$langs->trans("DemandReasonType".$obj->code):($obj->label!='-'?$obj->label:'')); $label=($langs->trans("DemandReasonType".$obj->code)!=("DemandReasonType".$obj->code)?$langs->trans("DemandReasonType".$obj->code):($obj->label!='-'?$obj->label:''));
$this->cache_demand_reason[$obj->rowid]['code'] =$obj->code; $tmparray[$obj->rowid]['id'] =$obj->rowid;
$this->cache_demand_reason[$obj->rowid]['label']=$label; $tmparray[$obj->rowid]['code'] =$obj->code;
$tmparray[$obj->rowid]['label']=$label;
$i++; $i++;
} }
$this->cache_demand_reason=dol_sort_array($tmparray,'label');
//var_dump($this->cache_demand_reason);exit;
unset($tmparray);
return 1; return 1;
} }
else { else {
@@ -1573,29 +1578,31 @@ class Form
} }
/** /**
* \brief Retourne la liste des types d'origine de propal/commande possibles * Return list of events that triggered an object creation
* \param selected Id du type d'origine pre-selectionne * @param selected Id du type d'origine pre-selectionne
* \param htmlname Nom de la zone select * @param htmlname Nom de la zone select
* \param filtertype Pour filtre * @param exclude To exclude a code value (Example: SRC_PROP)
* \param addempty Ajoute entree vide * @param addempty Add an empty entry
*/ */
function select_demand_reason($selected='',$htmlname='demandreasonid',$filtertype='',$addempty=0) function select_demand_reason($selected='',$htmlname='demandreasonid',$exclude='',$addempty=0)
{ {
global $langs,$user; global $langs,$user;
$this->load_cache_demand_reason(); $this->load_cache_demand_reason();
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
if ($addempty) print '<option value="0">&nbsp;</option>'; if ($addempty) print '<option value="0"'.(empty($selected)?' selected="selected"':'').'>&nbsp;</option>';
foreach($this->cache_demand_reason as $id => $arraydemandreason) foreach($this->cache_demand_reason as $id => $arraydemandreason)
{ {
if ($selected == $id) if ($arraydemandreason['code']==$exclude) continue;
if ($selected == $arraydemandreason['id'])
{ {
print '<option value="'.$id.'" selected="selected">'; print '<option value="'.$arraydemandreason['id'].'" selected="selected">';
} }
else else
{ {
print '<option value="'.$id.'">'; print '<option value="'.$arraydemandreason['id'].'">';
} }
print $arraydemandreason['label']; print $arraydemandreason['label'];
print '</option>'; print '</option>';
@@ -2235,11 +2242,11 @@ class Form
} }
/** /**
* \brief Affiche formulaire de selection d'origine de propal/commande * Affiche formulaire de selection d'origine de propal/commande
* \param page Page * @param page Page
* \param selected Id condition pre-selectionne * @param selected Id condition pre-selectionne
* \param htmlname Name of select html field * @param htmlname Name of select html field
* \param addempty Ajoute entree vide * @param addempty Ajoute entree vide
*/ */
function form_demand_reason($page, $selected='', $htmlname='demandreason', $addempty=0) function form_demand_reason($page, $selected='', $htmlname='demandreason', $addempty=0)
{ {
@@ -2261,7 +2268,14 @@ class Form
if ($selected) if ($selected)
{ {
$this->load_cache_demand_reason(); $this->load_cache_demand_reason();
print $this->cache_demand_reason[$selected]['label']; foreach ($this->cache_demand_reason as $key => $val)
{
if ($val['id'] == $selected)
{
print $val['label'];
break;
}
}
} else { } else {
print "&nbsp;"; print "&nbsp;";
} }

View File

@@ -0,0 +1,32 @@
-- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2011 Philippe Grand
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
--
-- $Id$
--
--
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (1, 'SRC_INTE', 'Web site', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (2, 'SRC_CAMP_MAIL', 'Mailing campaign', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (3, 'SRC_CAMP_PHO', 'Phone campaign', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (4, 'SRC_CAMP_FAX', 'Fax campaign', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (5, 'SRC_COMM', 'Commercial contact', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (6, 'SRC_SHOP', 'Shop contact', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (7, 'SRC_CAMP_EMAIL', 'EMailing campaign', 1);

View File

@@ -65,15 +65,24 @@ CREATE TABLE llx_c_availability
)ENGINE=innodb; )ENGINE=innodb;
CREATE TABLE llx_c_demand_reason -- Use table name input_reason to match also input_method
DROP table llx_c_demand_reason;
CREATE TABLE llx_c_input_reason
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
code varchar(30) NOT NULL, code varchar(30) NOT NULL,
label varchar(60) NOT NULL, label varchar(60) NOT NULL,
active tinyint DEFAULT 1 NOT NULL active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb; )ENGINE=innodb;
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (1, 'SRC_INTE', 'Web site', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (2, 'SRC_CAMP_MAIL', 'Mailing campaign', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (3, 'SRC_CAMP_PHO', 'Phone campaign', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (4, 'SRC_CAMP_FAX', 'Fax campaign', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (5, 'SRC_COMM', 'Commercial contact', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (6, 'SRC_SHOP', 'Shop contact', 1);
INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (7, 'SRC_CAMP_EMAIL', 'EMailing campaign', 1);
ALTER TABLE llx_propal CHANGE COLUMN delivery fk_availability integer NULL; ALTER TABLE llx_propal CHANGE COLUMN delivery fk_availability integer NULL;
ALTER TABLE llx_propal ADD COLUMN fk_availability integer NULL AFTER date_livraison; ALTER TABLE llx_propal ADD COLUMN fk_availability integer NULL AFTER date_livraison;
ALTER TABLE llx_commande ADD COLUMN fk_availability integer NULL AFTER date_livraison; ALTER TABLE llx_commande ADD COLUMN fk_availability integer NULL AFTER date_livraison;
@@ -83,14 +92,6 @@ INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (2, 'AV_1W', '1
INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', '2 weeks', 1); INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', '2 weeks', 1);
INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', '3 weeks', 1); INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', '3 weeks', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (1, 'SRC_00', 'Proposition commerciale', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (2, 'SRC_01', 'Internet', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (3, 'SRC_02', 'Campagne courrier', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (4, 'SRC_03', 'Campagne téléphone', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (5, 'SRC_04', 'Campagne fax', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (6, 'SRC_05', 'Commercial', 1);
INSERT INTO llx_c_demand_reason (rowid,code,label,active) VALUES (7, 'SRC_06', 'Magasin', 1);
ALTER TABLE llx_actioncomm ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; ALTER TABLE llx_actioncomm ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id;
ALTER TABLE llx_propaldet ADD INDEX idx_propaldet_fk_product (fk_product); ALTER TABLE llx_propaldet ADD INDEX idx_propaldet_fk_product (fk_product);

View File

@@ -3512,6 +3512,12 @@ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
* ascending (default) or descending output and uses optionally * ascending (default) or descending output and uses optionally
* natural case insensitive sorting (which can be optionally case * natural case insensitive sorting (which can be optionally case
* sensitive as well). * sensitive as well).
* @param array Array to sort
* @param index
* @param order
* @param natsort
* @param cas_sensitive
* @return Sorted array
*/ */
function dol_sort_array(&$array, $index, $order='asc', $natsort, $case_sensitive) function dol_sort_array(&$array, $index, $order='asc', $natsort, $case_sensitive)
{ {