diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 5015b6f8e0d..b061da85326 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -77,7 +77,7 @@ $tabname[18]= MAIN_DB_PREFIX."c_shipment_mode"; $tabname[19]= MAIN_DB_PREFIX."c_effectif"; $tabname[20]= MAIN_DB_PREFIX."c_input_method"; $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 $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[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[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 $tabsqlsort[1] ="pays ASC, code ASC"; diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index cbdfb02f455..1bd6f22e647 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2011 Philippe Grand @@ -43,6 +43,13 @@ $langs->load("bills"); $langs->load("orders"); $langs->load("deliveries"); +/* + * Actions + */ + +// None + + /* * View @@ -55,9 +62,7 @@ print_fiche_titre($langs->trans("NewProp")); $html=new Form($db); -/* - * Creation d'une nouvelle propale - */ +// Add new proposal if ($_GET["action"] == 'create') { $soc = new Societe($db); @@ -127,9 +132,7 @@ if ($_GET["action"] == 'create') print ''; print ''; - /* - * Contact de la propale - */ + // Contacts print "".$langs->trans("DefaultContact")."\n"; $html->select_contacts($soc->id,$setcontact,'contactidp',1); print ''; @@ -161,15 +164,15 @@ if ($_GET["action"] == 'create') print ''.$langs->trans('PaymentMode').''; $html->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); print ''; - - // Source de propale + + // What trigger creation print ''.$langs->trans('Source').''; - $html->select_demand_reason($soc->demand_reason,'demand_reason_id'); + $html->select_demand_reason($propal->demand_reason,'demand_reason_id',"SRC_PROP",1); print ''; // delai de livraison print ''.$langs->trans('AvailabilityPeriod').''; - $html->select_availability($soc->availability,'availability_id'); + $html->select_availability($propal->availability,'availability_id'); print ''; // Delivery date (or manufacturing) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 44efe37695d..e92b5d90d7c 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1321,9 +1321,10 @@ if ($id > 0 || ! empty($ref)) if ($action != 'editdemandreason' && $object->brouillon) print 'id.'">'.img_edit($langs->trans('SetDemandReason'),1).''; print ''; print ''; + //print $object->demand_reason_id; 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 { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 71749ff7043..5c2a148838c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -405,7 +405,7 @@ class Propal extends CommonObject { // Reorder if child line if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); - + // Mise a jour informations denormalisees au niveau de la propale meme $result=$this->update_price(1); if ($result > 0) @@ -482,15 +482,15 @@ class Propal extends CommonObject $remise = round(($pu * $remise_percent / 100), 2); $price = $pu - $remise; } - + // Update line $this->line=new PropaleLigne($this->db); - + // Stock previous line records $staticline=new PropaleLigne($this->db); $staticline->fetch($rowid); $this->line->oldline = $staticline; - + $this->line->rowid=$rowid; $this->line->desc=$desc; $this->line->qty=$qty; @@ -508,13 +508,13 @@ class Propal extends CommonObject $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; $this->line->skip_update_total=$skip_update_total; - + if (empty($qty) && empty($special_code)) $this->line->special_code=3; - + // TODO deprecated $this->line->price=$price; $this->line->remise=$remise; - + $result=$this->line->update(); if ($result > 0) { @@ -552,7 +552,7 @@ class Propal extends CommonObject if ($this->statut == 0) { $line=new PropaleLigne($this->db); - + // For triggers $line->fetch($lineid); @@ -685,14 +685,14 @@ class Propal extends CommonObject { $fk_parent_line=0; $num=sizeof($this->lines); - + for ($i=0;$i<$num;$i++) { // 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) { $fk_parent_line = 0; } - + $result = $this->addline( $this->id, $this->lines[$i]->desc, @@ -846,9 +846,9 @@ class Propal extends CommonObject // Load source object $object->fetch($fromid); $objFrom = $object; - + $objsoc=new Societe($this->db); - + // Change socid if needed if (! empty($socid) && $socid != $object->socid) { @@ -860,7 +860,7 @@ class Propal extends CommonObject $object->fk_project = ''; $object->fk_delivery_address = ''; } - + // TODO Change product price if multi-prices } 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_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_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.= " AND p.entity = ".$conf->entity; if ($ref) $sql.= " AND p.ref='".$ref."'"; @@ -1346,7 +1346,7 @@ class Propal extends CommonObject } } } - + /** * \brief Positionne numero reference client * \param user Utilisateur qui modifie @@ -1900,7 +1900,7 @@ class Propal extends CommonObject return -2; } } - + /** * \brief Change l'origine de la demande * \param demand_reason_id Id de la nouvelle origine de demande @@ -2379,7 +2379,7 @@ class PropaleLigne { var $db; var $error; - + var $oldline; // From llx_propaldet @@ -2421,12 +2421,12 @@ class PropaleLigne var $ref; // Reference produit var $libelle; // Label produit var $product_desc; // Description produit - + var $localtax1_tx; var $localtax2_tx; var $total_localtax1; var $total_localtax2; - + var $skip_update_total; // Skip update price total for special lines /** @@ -2579,7 +2579,7 @@ class PropaleLigne return -1; } } - + /** * Delete line in database * @return int <0 si ko, >0 si ok @@ -2587,9 +2587,9 @@ class PropaleLigne function delete() { global $conf,$langs,$user; - + $this->db->begin(); - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; dol_syslog("PropaleLigne::delete sql=".$sql, LOG_DEBUG); if ($this->db->query($sql) ) @@ -2600,9 +2600,9 @@ class PropaleLigne $result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - + $this->db->commit(); - + return 1; } else @@ -2613,7 +2613,7 @@ class PropaleLigne return -1; } } - + /** * \brief Mise a jour de l'objet ligne de propale en base * \return int <0 si ko, >0 si ok @@ -2621,7 +2621,7 @@ class PropaleLigne function update($notrigger=0) { global $conf,$langs,$user; - + // Clean parameters if (empty($this->tva_tx)) $this->tva_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->special_code)) $this->special_code=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0; - + $this->db->begin(); // Mise a jour ligne en base @@ -2677,7 +2677,7 @@ class PropaleLigne if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers } - + $this->db->commit(); return 1; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0a40a94a070..8604f3ed130 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -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_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_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.= " WHERE c.entity = ".$conf->entity; if ($ref) $sql.= " AND c.ref='".$ref."'"; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 93db1b1dacb..98199285dfc 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1274,15 +1274,15 @@ if ($action == 'create' && $user->rights->commande->creer) // delai de livraison print ''.$langs->trans('AvailabilityPeriod').''; - $html->select_availability($soc->availability,'availability_id'); + $html->select_availability($propal->availability,'availability_id'); print ''; - // Source de commande + // What trigger creation print ''.$langs->trans('Source').''; - $html->select_demand_reason($soc->demand_reason,'demand_reason_id'); + $html->select_demand_reason((GETPOST("origin")=='propal'?'SRC_COMM':''),'demand_reason_id','',1); print ''; - // Projet + // Project if ($conf->projet->enabled) { $projectid = 0; @@ -1297,10 +1297,6 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } - print ''.$langs->trans('Source').''; - $formorder->selectSourcesCommande((GETPOST("origin")=='propal'?'0':''),'source_id',1); - print ''; - print ''.$langs->trans('Model').''; print ''; // pdf @@ -1770,7 +1766,7 @@ else print ''; 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 { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1120e901b87..f7112aec4e9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1535,17 +1535,17 @@ class Form } /** - * \brief Charge dans cache la liste des origines de commande possibles - * \return int Nb lignes chargees, 0 si deja chargees, <0 si ko + * Load into cache cache_demand_reason, array of input reasons + * @return int Nb of lines loaded, 0 if already loaded, <0 if ko */ function load_cache_demand_reason() { 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.= " FROM ".MAIN_DB_PREFIX.'c_demand_reason'; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; $sql.= " WHERE active=1"; $sql.= " ORDER BY rowid"; dol_syslog('Form::load_cache_demand_reason sql='.$sql,LOG_DEBUG); @@ -1554,16 +1554,21 @@ class Form { $num = $this->db->num_rows($resql); $i = 0; + $tmparray=array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); // 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:'')); - $this->cache_demand_reason[$obj->rowid]['code'] =$obj->code; - $this->cache_demand_reason[$obj->rowid]['label']=$label; + $tmparray[$obj->rowid]['id'] =$obj->rowid; + $tmparray[$obj->rowid]['code'] =$obj->code; + $tmparray[$obj->rowid]['label']=$label; $i++; } + $this->cache_demand_reason=dol_sort_array($tmparray,'label'); + //var_dump($this->cache_demand_reason);exit; + unset($tmparray); return 1; } else { @@ -1573,29 +1578,31 @@ class Form } /** - * \brief Retourne la liste des types d'origine de propal/commande possibles - * \param selected Id du type d'origine pre-selectionne - * \param htmlname Nom de la zone select - * \param filtertype Pour filtre - * \param addempty Ajoute entree vide + * Return list of events that triggered an object creation + * @param selected Id du type d'origine pre-selectionne + * @param htmlname Nom de la zone select + * @param exclude To exclude a code value (Example: SRC_PROP) + * @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; $this->load_cache_demand_reason(); print '