Fix Edit of extrafield on supplier invoice or order was deleteing other

fields.
Fix Missing escapment
Fix new field delivery date was only into edit page
This commit is contained in:
Laurent Destailleur 2015-02-22 17:41:02 +01:00
parent 1ca4e377d5
commit b04682db4c
5 changed files with 23 additions and 13 deletions

View File

@ -31,6 +31,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("orders");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();

View File

@ -1062,7 +1062,7 @@ class ExtraFields
* *
* @param array $extralabels $array of extrafields * @param array $extralabels $array of extrafields
* @param object $object Object * @param object $object Object
* @param string $onlykey Only following key is filled * @param string $onlykey Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
* @return int 1 if array_options set / 0 if no value * @return int 1 if array_options set / 0 if no value
*/ */
function setOptionalsFromPost($extralabels,&$object,$onlykey='') function setOptionalsFromPost($extralabels,&$object,$onlykey='')

View File

@ -887,7 +887,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", entity"; $sql.= ", entity";
$sql.= ", fk_soc"; $sql.= ", fk_soc";
$sql.= ", date_creation"; $sql.= ", date_creation";
//$sql.= ", date_livraison"; $sql.= ", date_livraison";
$sql.= ", fk_user_author"; $sql.= ", fk_user_author";
$sql.= ", fk_statut"; $sql.= ", fk_statut";
$sql.= ", source"; $sql.= ", source";
@ -899,12 +899,12 @@ class CommandeFournisseur extends CommonOrder
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "''"; $sql.= "''";
$sql.= ", '".$this->ref_supplier."'"; $sql.= ", '".$this->ref_supplier."'";
$sql.= ", '".$this->note_private."'"; $sql.= ", '".$this->db->escape($this->note_private)."'";
$sql.= ", '".$this->note_public."'"; $sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ", ".$this->socid; $sql.= ", ".$this->socid;
$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($now)."'";
//$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
$sql.= ", ".$user->id; $sql.= ", ".$user->id;
$sql.= ", 0"; $sql.= ", 0";
$sql.= ", " . $this->source; $sql.= ", " . $this->source;

View File

@ -69,6 +69,8 @@ $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (!
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
$datelivraison=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), GETPOST('liv_sec','int'), GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
@ -144,8 +146,6 @@ if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer)
// date de livraison // date de livraison
if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer) if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer)
{ {
$datelivraison=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), GETPOST('liv_sec','int'), GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
$result=$object->set_date_livraison($user,$datelivraison); $result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0) if ($result < 0)
{ {
@ -780,9 +780,8 @@ if ($action == 'update_extras')
{ {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
if ($ret < 0) $error++;
if($ret < 0) $error++;
if (!$error) if (!$error)
{ {
@ -797,7 +796,6 @@ if ($action == 'update_extras')
{ {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$result=$object->insertExtraFields(); $result=$object->insertExtraFields();
if ($result < 0) if ($result < 0)
@ -841,6 +839,7 @@ if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$object->fk_account = GETPOST('fk_account', 'int'); $object->fk_account = GETPOST('fk_account', 'int');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public');
$object->date_livraison = $datelivraison;
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -1272,6 +1271,16 @@ if ($action=="create")
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
print '</td></tr>'; print '</td></tr>';
// Planned delivery date
print '<tr><td>';
print $langs->trans('DateDeliveryPlanned');
print '</td>';
print '<td>';
$usehourmin=0;
if (! empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin=1;
$form->select_date($datelivraison?$datelivraison:-1,'liv_',$usehourmin,$usehourmin,'',"set");
print '</td></tr>';
// Bank Account // Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled)) if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled))
{ {

View File

@ -1070,7 +1070,7 @@ elseif ($action == 'update_extras')
{ {
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels,$object); $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
if($ret < 0) $error++; if($ret < 0) $error++;