From f29ee25ea751400a84c80a6f519052a3aa587a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 27 Oct 2018 11:06:45 +0200 Subject: [PATCH] remove fieldlabel and add fieldeditkey --- htdocs/commande/card.php | 142 ++++++++++------------------------ htdocs/core/tpl/notes.tpl.php | 3 +- 2 files changed, 44 insertions(+), 101 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f468bd4b146..3036722c3aa 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1687,7 +1687,7 @@ if ($action == 'create' && $user->rights->commande->creer) if (! empty($conf->multicurrency->enabled)) { print ''; - print ''.fieldLabel('Currency','multicurrency_code').''; + print ''.$form->editfieldkey("Currency", 'multicurrency_code', '', $object, 0).''; print ''; print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print ''; @@ -2074,13 +2074,8 @@ if ($action == 'create' && $user->rights->commande->creer) // Date print ''; - print ''; - - if ($action != 'editdate' && $object->brouillon) - print ''; - print '
'; - print $langs->trans('Date'); - print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; + $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; + print $form->editfieldkey("Date", 'date', '', $object, $editenable); print ''; if ($action == 'editdate') { print '
'; @@ -2100,12 +2095,8 @@ if ($action == 'create' && $user->rights->commande->creer) // Delivery date planed print ''; - print ''; - if ($action != 'editdate_livraison') - print ''; - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print 'id . '">' . img_edit($langs->trans('SetDeliveryDate'), 1) . '
'; + $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; + print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); print ''; if ($action == 'editdate_livraison') { print ''; @@ -2125,13 +2116,9 @@ if ($action == 'create' && $user->rights->commande->creer) // Shipping Method if (! empty($conf->expedition->enabled)) { - print ''; - print ''; - if ($action != 'editshippingmethod' && $user->rights->commande->creer) - print ''; - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetShippingMode'),1).'
'; + print ''; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); print ''; if ($action == 'editshippingmethod') { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); @@ -2144,15 +2131,12 @@ if ($action == 'create' && $user->rights->commande->creer) // Warehouse if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + $langs->load('stocks'); require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct=new FormProduct($db); print ''; - print ''; - if ($action != 'editwarehouse' && $user->rights->commande->creer) - print ''; - print '
'; - print $langs->trans('Warehouse'); - print 'id.'">'.img_edit($langs->trans('SetWarehouse'),1).'
'; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); print ''; if ($action == 'editwarehouse') { $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1); @@ -2165,12 +2149,8 @@ if ($action == 'create' && $user->rights->commande->creer) // Terms of payment print ''; - print ''; - if ($action != 'editconditions') - print ''; - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . '
'; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); print ''; if ($action == 'editconditions') { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); @@ -2183,12 +2163,8 @@ if ($action == 'create' && $user->rights->commande->creer) // Mode of payment print ''; - print ''; - if ($action != 'editmode') - print ''; - print '
'; - print $langs->trans('PaymentMode'); - print 'id . '">' . img_edit($langs->trans('SetMode'), 1) . '
'; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); print ''; if ($action == 'editmode') { $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id'); @@ -2203,12 +2179,8 @@ if ($action == 'create' && $user->rights->commande->creer) // Multicurrency code print ''; print ''; - print ''; - if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) - print ''; - print '
'; - print fieldLabel('Currency','multicurrency_code'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT; + print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable); print ''; if ($action == 'editmulticurrencycode') { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); @@ -2220,12 +2192,8 @@ if ($action == 'create' && $user->rights->commande->creer) // Multicurrency rate print ''; print ''; - print ''; - if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print ''; - print '
'; - print fieldLabel('CurrencyRate','multicurrency_tx'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + $editenable = $user->rights->commande->creer && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT; + print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable); print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if($action == 'actualizemulticurrencyrate') { @@ -2244,13 +2212,9 @@ if ($action == 'create' && $user->rights->commande->creer) } // Delivery delay - print ''; - print ''; - if ($action != 'editavailability') - print ''; - print '
'; - print $langs->trans('AvailabilityPeriod'); - print 'id . '">' . img_edit($langs->trans('SetAvailability'), 1) . '
'; + print ''; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); print ''; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); @@ -2260,13 +2224,9 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; // Source reason (why we have an ordrer) - print ''; - print ''; - if ($action != 'editdemandreason') - print ''; - print '
'; - print $langs->trans('Channel'); - print 'id . '">' . img_edit($langs->trans('SetDemandReason'), 1) . '
'; + print ''; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); print ''; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); @@ -2277,13 +2237,9 @@ if ($action == 'create' && $user->rights->commande->creer) // TODO Order mode (how we receive order). Not yet implemented /* - print ''; - print ''; - if ($action != 'editinputmode') - print ''; - print '
'; - print $langs->trans('SourceMode'); - print 'id . '">' . img_edit($langs->trans('SetInputMode'), 1) . '
'; + print ''; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable); print ''; if ($action == 'editinputmode') { $form->formInputMode($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->source, 'input_mode_id', 1); @@ -2296,15 +2252,13 @@ if ($action == 'create' && $user->rights->commande->creer) $tmparray=$object->getTotalWeightVolume(); $totalWeight=$tmparray['weight']; $totalVolume=$tmparray['volume']; - if ($totalWeight) - { + if ($totalWeight) { print ''.$langs->trans("CalculatedWeight").''; print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); print ''; } - if ($totalVolume) - { + if ($totalVolume) { print ''.$langs->trans("CalculatedVolume").''; print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); @@ -2314,15 +2268,10 @@ if ($action == 'create' && $user->rights->commande->creer) // TODO How record was recorded OrderMode (llx_c_input_method) // Incoterms - if (!empty($conf->incoterm->enabled)) - { + if (!empty($conf->incoterm->enabled)) { print ''; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->commande->creer) print ''.img_edit().''; - else print ' '; - print '
'; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); print ''; print ''; if ($action != 'editincoterm') @@ -2337,15 +2286,10 @@ if ($action == 'create' && $user->rights->commande->creer) } // Bank Account - if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) - { - print ''; - print ''; - print '
'; - print $langs->trans('BankAccount'); - print ''; - if ($action != 'editbankaccount' && $user->rights->commande->creer) - print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { + print ''; + $editenable = $user->rights->commande->creer; + print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); @@ -2446,12 +2390,11 @@ if ($action == 'create' && $user->rights->commande->creer) */ $result = $object->getLinesArray(); - print ' + print ' - - '; + '; if (! empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; @@ -2518,10 +2461,11 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } // Create event - /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a - // "workflow" action so should appears somewhere else on - // page. + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) { + // Add hidden condition because this is not a + // "workflow" action so should appears somewhere else on + // page. print '' . $langs->trans("AddAction") . ''; }*/ diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 39132dd1af7..0d2151ab62d 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -18,8 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($object) || ! is_object($object)) -{ +if (empty($object) || ! is_object($object)) { print "Error, template page can't be called as URL"; exit; }