From 010f2cd9b8edb363b2c42e9b60530861507151bb Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 31 Oct 2023 11:54:18 +0100 Subject: [PATCH] New : Add hook tabContentViewProposal (#26400) * add hook tabContentViewProposal * update credentials --------- Co-authored-by: Christophe Battarel --- htdocs/comm/propal/card.php | 857 ++++++++++++++++++------------------ 1 file changed, 431 insertions(+), 426 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e686109871f..3b317504c7f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -7,7 +7,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2023 Juanjo Menent * Copyright (C) 2010-2022 Philippe Grand - * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012-2023 Christophe Battarel * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Ferran Marcet @@ -2474,479 +2474,484 @@ if ($action == 'create') { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + // Call Hook tabContentViewProposal + $parameters = array(); + // Note that $action and $object may be modified by hook + $reshook = $hookmanager->executeHooks('tabContentViewProposal', $parameters, $object, $action); + if (empty($reshook)) { + print '
'; + print '
'; + print '
'; - print '
'; - print '
'; - print '
'; + print ''; - print '
'; - - // Link for thirdparty discounts - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; - } - - print ''; - - // Date of proposal - print ''; - print ''; - // Date end proposal - print ''; - print ''; - print ''; + print ''; - print ''; + $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); + $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - // Payment mode - print ''; - print ''; + $caneditfield = ($object->statut != Propal::STATUS_SIGNED && $object->statut != Propal::STATUS_BILLED); - // Delivery date - $langs->load('deliveries'); - print ''; - print ''; + $thirdparty = $soc; + $discount_type = 0; + $backtopage = $_SERVER["PHP_SELF"].'?id='.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - // Delivery delay - print ''; - print ''; - print ''; - - // Shipping Method - if (isModEnabled("expedition")) { - print ''; - print ''; - } - - // Warehouse - if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) { - $langs->load('stocks'); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $formproduct = new FormProduct($db); - print ''; - print ''; - } - - // Origin of demand - print ''; - print ''; - - // Multicurrency - if (isModEnabled("multicurrency")) { - // Multicurrency code + // Date of proposal print ''; print '
'.$langs->trans('Discounts').''; - - $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); - $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); - $absolute_discount = price2num($absolute_discount, 'MT'); - $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - - $caneditfield = ($object->statut != Propal::STATUS_SIGNED && $object->statut != Propal::STATUS_BILLED); - - $thirdparty = $soc; - $discount_type = 0; - $backtopage = $_SERVER["PHP_SELF"].'?id='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - - print '
'; - // print ''; - // if ($action != 'editdate' && $usercancreate && $caneditfield) { - // print ''; - // } - - // print '
'; - // print $langs->trans('DatePropal'); - // print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; - $editenable = $usercancreate && $caneditfield && $object->statut == Propal::STATUS_DRAFT; - print $form->editfieldkey("DatePropal", 'date', '', $object, $editenable); - print '
'; - if ($action == 'editdate' && $usercancreate && $caneditfield) { - print '
'; - print ''; - print ''; - print ''; - print $form->selectDate($object->date, 're', '', '', 0, "editdate"); - print ''; - print '
'; - } else { - if ($object->date) { - print dol_print_date($object->date, 'day'); + // Link for thirdparty discounts + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { - print ' '; + $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - } - print '
'; - print ''; - if ($action != 'editecheance' && $usercancreate && $caneditfield) { - print ''; - } - print '
'; - print $langs->trans('DateEndPropal'); - print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; - print '
'; - if ($action == 'editecheance' && $usercancreate && $caneditfield) { - print '
'; - print ''; - print ''; - print ''; - print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance"); - print ''; - print '
'; - } else { - if (!empty($object->fin_validite)) { - print dol_print_date($object->fin_validite, 'day'); - if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) { - print img_warning($langs->trans("Late")); - } - } else { - print ' '; - } - } - print '
'.$langs->trans('Discounts').''; - // Payment term - print '
'; - print ''; - if ($action != 'editconditions' && $usercancreate && $caneditfield) { - print ''; - } - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'
'; - print '
'; - if ($action == 'editconditions' && $usercancreate && $caneditfield) { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, '', 1, $object->deposit_percent); - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 0, '', 1, $object->deposit_percent); - } - print '
'; - print ''; - if ($action != 'editmode' && $usercancreate && $caneditfield) { - print ''; - } - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'
'; - print '
'; - if ($action == 'editmode' && $usercancreate && $caneditfield) { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); - } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); - } - print '
'; - print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); - print '
'; - print ''; - if ($action != 'editavailability' && $usercancreate && $caneditfield) { - print ''; - } - print '
'; - if (isModEnabled('commande')) { - print $form->textwithpicto($langs->trans('AvailabilityPeriod'), $langs->trans('AvailabilityPeriod').' ('.$langs->trans('AfterOrder').')'); - } else { - print $langs->trans('AvailabilityPeriod'); - } - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).'
'; - print '
'; - if ($action == 'editavailability' && $usercancreate && $caneditfield) { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); - } else { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); - } + print '
'; - print ''; - if ($action != 'editshippingmethod' && $usercancreate && $caneditfield) { - print ''; - } - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'
'; - print '
'; - if ($action == 'editshippingmethod' && $usercancreate && $caneditfield) { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); - } else { - $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); - } - print '
'; - $editenable = $usercancreate; - 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); - } else { - $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); - } - print '
'; - print ''; - if ($action != 'editdemandreason' && $usercancreate) { - print ''; - } - print '
'; - print $langs->trans('Source'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).'
'; - print '
'; - if ($action == 'editdemandreason' && $usercancreate) { - $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); - } else { - $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); - } - print '
'; - print ''; - if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) { - print ''; + + // Date end proposal + print ''; + print ''; + print ''; + + // Payment term + print ''; + print ''; + + // Payment mode + print ''; + print ''; - // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { - print ''; - print '
'; - print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + // print ''; + // if ($action != 'editdate' && $usercancreate && $caneditfield) { + // print ''; + // } + + // print '
'; + // print $langs->trans('DatePropal'); + // print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; + $editenable = $usercancreate && $caneditfield && $object->statut == Propal::STATUS_DRAFT; + print $form->editfieldkey("DatePropal", 'date', '', $object, $editenable); + print '
'; + if ($action == 'editdate' && $usercancreate && $caneditfield) { + print '
'; + print ''; + print ''; + print ''; + print $form->selectDate($object->date, 're', '', '', 0, "editdate"); + print ''; + print '
'; + } else { + if ($object->date) { + print dol_print_date($object->date, 'day'); + } else { + print ' '; + } + } print '
id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print ''; + if ($action != 'editecheance' && $usercancreate && $caneditfield) { + print ''; } print '
'; + print $langs->trans('DateEndPropal'); + print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; print '
'; - if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); + if ($action == 'editecheance' && $usercancreate && $caneditfield) { + print '
'; + print ''; + print ''; + print ''; + print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance"); + print ''; + print '
'; } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); + if (!empty($object->fin_validite)) { + print dol_print_date($object->fin_validite, 'day'); + if ($object->statut == Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) { + print img_warning($langs->trans("Late")); + } + } else { + print ' '; + } + } + print '
'; + print ''; + if ($action != 'editconditions' && $usercancreate && $caneditfield) { + print ''; + } + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'
'; + print '
'; + if ($action == 'editconditions' && $usercancreate && $caneditfield) { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, '', 1, $object->deposit_percent); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 0, '', 1, $object->deposit_percent); + } + print '
'; + print ''; + if ($action != 'editmode' && $usercancreate && $caneditfield) { + print ''; + } + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'
'; + print '
'; + if ($action == 'editmode' && $usercancreate && $caneditfield) { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + } else { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } print '
'; - print ''; - print ''; + print ''; + + // Delivery delay + print ''; + print ''; + + // Shipping Method + if (isModEnabled("expedition")) { + print ''; + print ''; + print ''; } - } - if ($soc->outstanding_limit) { - // Outstanding Bill - print ''; - print ''; - } + // Warehouse + if (isModEnabled('stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) { + $langs->load('stocks'); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + print ''; + print ''; + } - if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled("banque")) { - // Bank Account + // Origin of demand print '
'; - print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + // Delivery date + $langs->load('deliveries'); + print '
'; + print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield, 'datepicker'); + print '
'; + print ''; + if ($action != 'editavailability' && $usercancreate && $caneditfield) { + print ''; + } + print '
'; + if (isModEnabled('commande')) { + print $form->textwithpicto($langs->trans('AvailabilityPeriod'), $langs->trans('AvailabilityPeriod').' ('.$langs->trans('AfterOrder').')'); + } else { + print $langs->trans('AvailabilityPeriod'); + } + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).'
'; + print '
'; + if ($action == 'editavailability' && $usercancreate && $caneditfield) { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); + } else { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'none', 1); + } + + print '
'; + print ''; - if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) { - print ''; + if ($action != 'editshippingmethod' && $usercancreate && $caneditfield) { + print ''; } print '
'; + print $langs->trans('SendingMethod'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'
'; print '
'; - if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { - if ($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + if ($action == 'editshippingmethod' && $usercancreate && $caneditfield) { + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; - } + $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); } - print '
'; - print $langs->trans('OutstandingBill'); - print ''; - $arrayoutstandingbills = $soc->getOutstandingBills(); - print ($arrayoutstandingbills['opened'] > $soc->outstanding_limit ? img_warning() : ''); - print price($arrayoutstandingbills['opened']).' / '; - print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency); - print '
'; + $editenable = $usercancreate; + 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); + } else { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none'); + } + print '
'; - print ''; print ''; - } - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - if ($totalWeight) { - print ''; - print ''; - } - if ($totalVolume) { - print ''; - print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans('BankAccount'); + print ''; - if ($action != 'editbankaccount' && $usercancreate) { - print ''; + if ($action != 'editdemandreason' && $usercancreate) { + print ''; } print '
'; + print $langs->trans('Source'); print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).'
'; print '
'; - if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + if ($action == 'editdemandreason' && $usercancreate) { + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'none'); } print '
'.$langs->trans("CalculatedWeight").''; - 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', 0); - print '
'.$langs->trans("CalculatedVolume").''; - 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', 0); - print '
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($action != 'editincoterm' && $usercancreate && $caneditfield) { - print ''.img_edit().''; - } else { - print ' '; - } - print '
'; - print '
'; - if ($action == 'editincoterm' && $usercancreate && $caneditfield) { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } else { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } - print '
'; - - print ''; - print '
'; - print '
'; - - print ''; - - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + // Multicurrency + if (isModEnabled("multicurrency")) { + // Multicurrency code print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; + print ''; + + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + print ''; + print ''; + } + } + + if ($soc->outstanding_limit) { + // Outstanding Bill + print ''; print ''; } - } - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - - print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ht, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_tva, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; + print ''; + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) { + print ''; } + print '
'; + print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print '
'; + if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); + } else { + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); + } + print '
'; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) { + print ''; + } + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print '
'; + if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { + if ($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } + } + print '
'; + print $langs->trans('OutstandingBill'); + print ''; + $arrayoutstandingbills = $soc->getOutstandingBills(); + print ($arrayoutstandingbills['opened'] > $soc->outstanding_limit ? img_warning() : ''); + print price($arrayoutstandingbills['opened']).' / '; + print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency); + print '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ttc, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
'; - - // Margin Infos - if (isModEnabled('margin')) { - $formmargin->displayMarginInfos($object); - } - - print '
'; - print ''; - - print '

'; - - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - /* - * Lines - */ - - // Get object lines - $result = $object->getLinesArray(); - - // Add products/services form - //$forceall = 1; - global $inputalsopricewithtax; - $inputalsopricewithtax = 1; - - print '
- - - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1); - } - - // Form to add new line - if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { - if ($action != 'editline') { - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, $soc); - } else { - $parameters = array(); - $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled("banque")) { + // Bank Account + print ''; + print ''; } - } - if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + if ($totalWeight) { + print ''; + print ''; + } + if ($totalVolume) { + print ''; + print ''; + } + + // Incoterms + if (isModEnabled('incoterm')) { + print ''; + print ''; + } + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + print '
'; + print ''; + if ($action != 'editbankaccount' && $usercancreate) { + print ''; + } + print '
'; + print $langs->trans('BankAccount'); + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; + print '
'; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print '
'.$langs->trans("CalculatedWeight").''; + 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', 0); + print '
'.$langs->trans("CalculatedVolume").''; + 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', 0); + print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($action != 'editincoterm' && $usercancreate && $caneditfield) { + print ''.img_edit().''; + } else { + print ' '; + } + print '
'; + print '
'; + if ($action == 'editincoterm' && $usercancreate && $caneditfield) { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } else { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } + print '
'; - } - print '
'; - print "
\n"; + print ''; + print '
'; + print '
'; + + print ''; + + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + } + } + + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + + print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ht, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_tva, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ttc, '', $langs, 1, -1, -1, $object->multicurrency_code) . '
'; + + // Margin Infos + if (isModEnabled('margin')) { + $formmargin->displayMarginInfos($object); + } + + print '
'; + print ''; + + print '

'; + + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + /* + * Lines + */ + + // Get object lines + $result = $object->getLinesArray(); + + // Add products/services form + //$forceall = 1; + global $inputalsopricewithtax; + $inputalsopricewithtax = 1; + + print '
+ + + + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->statut == Propal::STATUS_DRAFT) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1); + } + + // Form to add new line + if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { + if ($action != 'editline') { + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, $soc); + } else { + $parameters = array(); + $reshook = $hookmanager->executeHooks('formEditObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print "
\n"; + } print dol_get_fiche_end();