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:
parent
1ca4e377d5
commit
b04682db4c
@ -31,6 +31,7 @@ require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
$langs->load("orders");
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
@ -1061,8 +1061,8 @@ class ExtraFields
|
||||
* Fill array_options property of object by extrafields value (using for data sent by forms)
|
||||
*
|
||||
* @param array $extralabels $array of extrafields
|
||||
* @param object $object Object
|
||||
* @param string $onlykey Only following key is filled
|
||||
* @param object $object Object
|
||||
* @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
|
||||
*/
|
||||
function setOptionalsFromPost($extralabels,&$object,$onlykey='')
|
||||
|
||||
@ -887,7 +887,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= ", entity";
|
||||
$sql.= ", fk_soc";
|
||||
$sql.= ", date_creation";
|
||||
//$sql.= ", date_livraison";
|
||||
$sql.= ", date_livraison";
|
||||
$sql.= ", fk_user_author";
|
||||
$sql.= ", fk_statut";
|
||||
$sql.= ", source";
|
||||
@ -899,12 +899,12 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "''";
|
||||
$sql.= ", '".$this->ref_supplier."'";
|
||||
$sql.= ", '".$this->note_private."'";
|
||||
$sql.= ", '".$this->note_public."'";
|
||||
$sql.= ", '".$this->db->escape($this->note_private)."'";
|
||||
$sql.= ", '".$this->db->escape($this->note_public)."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", ".$this->socid;
|
||||
$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.= ", 0";
|
||||
$sql.= ", " . $this->source;
|
||||
|
||||
@ -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));
|
||||
$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
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
@ -144,8 +146,6 @@ if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer)
|
||||
// date de livraison
|
||||
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);
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -780,9 +780,8 @@ if ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from add form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if($ret < 0) $error++;
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
|
||||
if ($ret < 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
@ -797,7 +796,6 @@ if ($action == 'update_extras')
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
|
||||
$result=$object->insertExtraFields();
|
||||
|
||||
if ($result < 0)
|
||||
@ -841,6 +839,7 @@ if ($action == 'add' && $user->rights->fournisseur->commande->creer)
|
||||
$object->fk_account = GETPOST('fk_account', 'int');
|
||||
$object->note_private = GETPOST('note_private');
|
||||
$object->note_public = GETPOST('note_public');
|
||||
$object->date_livraison = $datelivraison;
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$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');
|
||||
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
|
||||
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && ! empty($conf->banque->enabled))
|
||||
{
|
||||
|
||||
@ -1070,7 +1070,7 @@ elseif ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from add form
|
||||
$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++;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user