From 010f2cd9b8edb363b2c42e9b60530861507151bb Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 31 Oct 2023 11:54:18 +0100 Subject: [PATCH 1/5] 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(); From 4c8870f205df09505929f70a8e1c6abfd44dce59 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 31 Oct 2023 11:54:39 +0100 Subject: [PATCH 2/5] add hook tabContentViewInvoice (#26402) Co-authored-by: Christophe Battarel --- htdocs/compta/facture/card.php | 1939 ++++++++++++++++---------------- 1 file changed, 972 insertions(+), 967 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a93a66854e7..e2decaa1aef 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2015 Juanjo Menent - * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012-2023 Christophe Battarel * Copyright (C) 2012-2013 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Jean-Francois FERRY @@ -4520,1076 +4520,1081 @@ if ($action == 'create') { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', ''); - print '
'; - print '
'; - print '
'; + // Call Hook tabContentViewInvoice + $parameters = array(); + // Note that $action and $object may be modified by hook + $reshook = $hookmanager->executeHooks('tabContentViewInvoice', $parameters, $object, $action); + if (empty($reshook)) { + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Type - print ''; + if ($objectidnext > 0) { + $facthatreplace = new Facture($db); + $facthatreplace->fetch($objectidnext); + print ' '.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).''; + } - // Relative and absolute discounts - print ''."\n"; - print ''; - print ''; + if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, $object->id); + if ($result > 0) { + print ' '; + $s = $langs->trans("CreditNoteConvertedIntoDiscount", '{s1}', '{s2}'); + $s = str_replace('{s1}', $object->getLibType(0), $s); + $s = str_replace('{s2}', $discount->getNomUrl(1, 'discount'), $s); + print $s; + print '
'; + } + } - // Date invoice - print ''; - if ($action == 'editinvoicedate') { - $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate'); - } else { - print ''.dol_print_date($object->date, 'day').''; - } - print ''; + // Relative and absolute discounts + print ''."\n"; + print ''; + print ''; - print ''; - - if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { - // Date invoice point of tax + // Date invoice print ''; - } - - // Payment term - print ''; - - // Date payment term - print ''; - - // Payment mode - print ''; - - // Multicurrency - if (isModEnabled('multicurrency')) { - // Multicurrency code - print ''; - print ''; - // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'.$langs->trans('Type').''; - print $object->getLibType(2); - print $object->getSubtypeLabel('facture'); - if ($object->module_source) { - print ' ('.$langs->trans("POS").' '.dol_escape_htmltag(ucfirst($object->module_source)).' - '.$langs->trans("Terminal").' '.dol_escape_htmltag($object->pos_source).')'; - } - if ($object->type == Facture::TYPE_REPLACEMENT) { - $facreplaced = new Facture($db); - $facreplaced->fetch($object->fk_facture_source); - print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1, '', 32)).''; - } - if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { - $facusing = new Facture($db); - $facusing->fetch($object->fk_facture_source); - print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1, '', 32)).''; - } + // Type + print '
'.$langs->trans('Type').''; + print $object->getLibType(2); + print $object->getSubtypeLabel('facture'); + if ($object->module_source) { + print ' ('.$langs->trans("POS").' '.dol_escape_htmltag(ucfirst($object->module_source)).' - '.$langs->trans("Terminal").' '.dol_escape_htmltag($object->pos_source).')'; + } + if ($object->type == Facture::TYPE_REPLACEMENT) { + $facreplaced = new Facture($db); + $facreplaced->fetch($object->fk_facture_source); + print ' '.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1, '', 32)).''; + } + if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { + $facusing = new Facture($db); + $facusing->fetch($object->fk_facture_source); + print ' '.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1, '', 32)).''; + } - $facidavoir = $object->getListIdAvoirFromInvoice(); - if (count($facidavoir) > 0) { - print ' '.$langs->transnoentities("InvoiceHasAvoir"); - $i = 0; - foreach ($facidavoir as $id) { - if ($i == 0) { - print ' '; - } else { - print ','; + $facidavoir = $object->getListIdAvoirFromInvoice(); + if (count($facidavoir) > 0) { + print ' '.$langs->transnoentities("InvoiceHasAvoir"); + $i = 0; + foreach ($facidavoir as $id) { + if ($i == 0) { + print ' '; + } else { + print ','; + } + $facavoir = new Facture($db); + $facavoir->fetch($id); + print $facavoir->getNomUrl(1, '', 32); } - $facavoir = new Facture($db); - $facavoir->fetch($id); - print $facavoir->getNomUrl(1, '', 32); - } - print ''; - } - if ($objectidnext > 0) { - $facthatreplace = new Facture($db); - $facthatreplace->fetch($objectidnext); - print ' '.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).''; - } - - if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { - $discount = new DiscountAbsolute($db); - $result = $discount->fetch(0, $object->id); - if ($result > 0) { - print ' '; - $s = $langs->trans("CreditNoteConvertedIntoDiscount", '{s1}', '{s2}'); - $s = str_replace('{s1}', $object->getLibType(0), $s); - $s = str_replace('{s2}', $discount->getNomUrl(1, 'discount'), $s); - print $s; - print '
'; - } - } - - if ($object->fk_fac_rec_source > 0) { - $tmptemplate = new FactureRec($db); - $result = $tmptemplate->fetch($object->fk_fac_rec_source); - if ($result > 0) { - print ' '; - $s = $langs->transnoentities("GeneratedFromTemplate", '{s1}'); - $s = str_replace('{s1}', $tmptemplate->getNomUrl(1, '', 32), $s); - print $s; print ''; } - } - print '
'.$langs->trans('DiscountStillRemaining').''; - $thirdparty = $soc; - $discount_type = 0; - $backtopage = $_SERVER["PHP_SELF"].'?facid='.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - print '
'; - print ''; - if ($action != 'editinvoicedate' && $object->status == $object::STATUS_DRAFT && $usercancreate && !getDolGlobalString('FAC_FORCE_DATE_VALIDATION')) { - print ''; - } - print '
'; - print $langs->trans('DateInvoice'); - print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; - print '
'; + if ($object->fk_fac_rec_source > 0) { + $tmptemplate = new FactureRec($db); + $result = $tmptemplate->fetch($object->fk_fac_rec_source); + if ($result > 0) { + print ' '; + $s = $langs->transnoentities("GeneratedFromTemplate", '{s1}'); + $s = str_replace('{s1}', $tmptemplate->getNomUrl(1, '', 32), $s); + print $s; + print ''; + } + } + print '
'.$langs->trans('DiscountStillRemaining').''; + $thirdparty = $soc; + $discount_type = 0; + $backtopage = $_SERVER["PHP_SELF"].'?facid='.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; + print '
'; print ''; - print ''; - print '
'; - print $langs->trans('DatePointOfTax'); + print $langs->trans('DateInvoice'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; - print '
'; - if ($action == 'editdate_pointoftax') { - $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_pointoftax, 'date_pointoftax'); - } else { - print ''.dol_print_date($object->date_pointoftax, 'day').''; - } - print '
'; - print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) { - print ''; - } - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; - print '
'; - if ($object->type != Facture::TYPE_CREDIT_NOTE) { - if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); - } - } else { - print ' '; - } - print '
'; - print ''; - if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) { - print ''; - } - print '
'; - print $langs->trans('DateMaxPayment'); - print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; - print '
'; - if ($object->type != Facture::TYPE_CREDIT_NOTE) { - if ($action == 'editpaymentterm') { - $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_lim_reglement, 'paymentterm'); - } else { - print ''.dol_print_date($object->date_lim_reglement, 'day').''; - if ($object->hasDelay()) { - print img_warning($langs->trans('Late')); - } - } - } else { - print ' '; - } - print '
'; - print ''; - if ($action != 'editmode' && $usercancreate) { - print ''; - } - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; - print '
'; - if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); - } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); - } - print '
'; - print ''; - if ($usercancreate && $action != 'editmulticurrencycode' && $object->status == $object::STATUS_DRAFT) { - print ''; + if ($action != 'editinvoicedate' && $object->status == $object::STATUS_DRAFT && $usercancreate && !getDolGlobalString('FAC_FORCE_DATE_VALIDATION')) { + print ''; } print '
'; - print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print '
'; - $htmlname = (($usercancreate && $action == 'editmulticurrencycode') ? 'multicurrency_code' : 'none'); - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname); - print '
'; - print ''; + + print ''; + + if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { + // Date invoice point of tax + print ''; } - } - // Bank Account - if (isModEnabled("banque")) { - print '
'; - print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + if ($action == 'editinvoicedate') { + $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate'); + } else { + print ''.dol_print_date($object->date, 'day').''; + } + print '
'; + print ''; - if ($usercancreate && $action != 'editmulticurrencyrate' && $object->status == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print ''; - } + print ''; print '
'; + print $langs->trans('DatePointOfTax'); print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; print '
'; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - 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, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code); + if ($action == 'editdate_pointoftax') { + $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_pointoftax, 'date_pointoftax'); } 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 ''.dol_print_date($object->date_pointoftax, 'day').''; } print '
'; - print ''; + // Payment term + print '"; - print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; - } - - - if (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - $displayWarranty = true; - if (!in_array($object->type, $retainedWarrantyInvoiceAvailableType) && empty($object->retained_warranty)) { - $displayWarranty = false; - } - - if ($displayWarranty) { - // Retained Warranty - print ''; - - // Retained warranty payment term - print ''; - - // Retained Warranty payment date limit - print ''; - } - } - - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans('BankAccount'); - print ''; - if (($action != 'editbankaccount') && $usercancreate) { - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; + print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) { + print ''; } print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->trans('SetConditions'), 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 "
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($usercancreate) { - print ''.img_edit().''; + if ($object->type != Facture::TYPE_CREDIT_NOTE) { + if ($action == 'editconditions') { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none'); + } } else { print ' '; } - print '
'; - print '
'; - if ($action != 'editincoterm') { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } print '
'; - print ''; - if ($action != 'editretainedwarranty' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { - print ''; - } - - print '
'; - print $langs->trans('RetainedWarranty'); - print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; - print '
'; - if ($action == 'editretainedwarranty' && $object->statut == Facture::STATUS_DRAFT) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - } else { - print price($object->retained_warranty).'%'; - } - print '
'; - print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { - print ''; - } - - print '
'; - print $langs->trans('PaymentConditionsShortRetainedWarranty'); - print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - print '
'; - $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); - if ($object->date > $defaultDate) { - $defaultDate = $object->date; - } - - if ($action == 'editretainedwarrantypaymentterms' && $object->statut == Facture::STATUS_DRAFT) { - //date('Y-m-d',$object->date_lim_reglement) - print '
'; - print ''; - print ''; - print ''; - $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - print $form->getSelectConditionsPaiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); - print ''; - print '
'; - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); - if (!$displayWarranty) { - print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); - } - } - print '
'; - print ''; - if ($action != 'editretainedwarrantydatelimit' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { - print ''; - } - - print '
'; - print $langs->trans('RetainedWarrantyDateLimit'); - print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'
'; - print '
'; - $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); - if ($object->date > $defaultDate) { - $defaultDate = $object->date; - } - - if ($action == 'editretainedwarrantydatelimit' && $object->statut == Facture::STATUS_DRAFT) { - //date('Y-m-d',$object->date_lim_reglement) - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - } else { - print dol_print_date($object->retained_warranty_date_limit, 'day'); - } - print '
'; - - print ''; - print '
'; - - print ''."\n"; - print '
'."\n"; - - print ''; - - $sign = 1; - if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) { - $sign = -1; // We invert sign for output - } - print ''; - // Amount HT - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - } - print ''; - - print ''; - // Amount VAT - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount VAT - print ''; - } - print ''; - - // Amount Local Taxes - if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(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" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - } - } - - - // Add the revenue stamp - if ($selleruserevenustamp) { - print ''; - } - print ''; - // Amount TTC - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount TTC - print ''; - } - print ''; - - print '
' . $langs->trans('AmountHT') . '' . price($sign * $object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountVAT') . '' . price($sign * $object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + // Date payment term + print '
'; print ''; - if ($action != 'editrevenuestamp' && $object->status == $object::STATUS_DRAFT && $usercancreate) { - print ''; + if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) { + print ''; } print '
'; - print $langs->trans('RevenueStamp'); + print $langs->trans('DateMaxPayment'); print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'id.'">'.img_edit($langs->trans('SetDate'), 1).'
'; - print '
'; - if ($action == 'editrevenuestamp') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code); - print ' → '; - print ' '; - print '
'; - print " "; + print '
'; + if ($object->type != Facture::TYPE_CREDIT_NOTE) { + if ($action == 'editpaymentterm') { + $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_lim_reglement, 'paymentterm'); + } else { + print ''.dol_print_date($object->date_lim_reglement, 'day').''; + if ($object->hasDelay()) { + print img_warning($langs->trans('Late')); + } + } } else { - print price($object->revenuestamp, 1, '', 1, -1, -1, $conf->currency); + print ' '; } print '
' . $langs->trans('AmountTTC') . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; - - $nbrows = 8; - $nbcols = 3; - if (isModEnabled('project')) { - $nbrows++; - } - if (isModEnabled("banque")) { - $nbrows++; - $nbcols++; - } - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { - $nbrows++; - } - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { - $nbrows++; - } - if ($selleruserevenustamp) { - $nbrows++; - } - if (isModEnabled('multicurrency')) { - $nbrows += 5; - } - if (isModEnabled('incoterm')) { - $nbrows += 1; - } - - // List of previous situation invoices - if (($object->situation_cycle_ref > 0) && !empty($conf->global->INVOICE_USE_SITUATION)) { - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - if (isModEnabled("banque")) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - - $total_prev_ht = $total_prev_ttc = 0; - $total_global_ht = $total_global_ttc = 0; - - if (count($object->tab_previous_situation_invoice) > 0) { - // List of previous invoices - - $current_situation_counter = array(); - foreach ($object->tab_previous_situation_invoice as $prev_invoice) { - $tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement(); - $total_prev_ht += $prev_invoice->total_ht; - $total_prev_ttc += $prev_invoice->total_ttc; - $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $prev_invoice->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (isModEnabled("banque")) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - } - } - - - $total_global_ht += $total_prev_ht; - $total_global_ttc += $total_prev_ttc; - $total_global_ht += $object->total_ht; - $total_global_ttc += $object->total_ttc; - $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $object->situation_counter; - print ''; - print ''; - print ''; - print ''; - if (isModEnabled("banque")) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - - - print ''; - print ''; - print ''; + // Multicurrency + if (isModEnabled('multicurrency')) { + // Multicurrency code + print ''; + print ''; - if (count($object->tab_next_situation_invoice) > 0) { - // List of next invoices - /*print ''; - print ''; - print ''; - print ''; - if (isModEnabled('banque')) print ''; - print ''; - print ''; - print ''; - print '';*/ - - $total_next_ht = $total_next_ttc = 0; - - foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaid = $next_invoice->getSommePaiement(); - $total_next_ht += $next_invoice->total_ht; - $total_next_ttc += $next_invoice->total_ttc; - - print ''; - print ''; - print ''; - print ''; - if (isModEnabled("banque")) { - print ''; + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + print ''; + print ''; + } + } + + // Bank Account + if (isModEnabled("banque")) { + print '"; + print ''; + } + + // Incoterms + if (isModEnabled('incoterm')) { + print ''; + print ''; + } + + + + if (!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { + $displayWarranty = true; + if (!in_array($object->type, $retainedWarrantyInvoiceAvailableType) && empty($object->retained_warranty)) { + $displayWarranty = false; } - $total_global_ht += $total_next_ht; - $total_global_ttc += $total_next_ttc; + if ($displayWarranty) { + // Retained Warranty + print ''; + + // Retained warranty payment term + print ''; + + // Retained Warranty payment date limit + print ''; + } + } + + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans('ListOfSituationInvoices').''.$langs->trans('Situation').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').' 
'.$prev_invoice->getNomUrl(1).''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$prev_invoice->situation_counter.''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).'
'.$object->getNomUrl(1).''.(($object->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$object->situation_counter.''.price($object->total_ht).''.price($object->total_ttc).''.$object->getLibStatut(3, $object->getSommePaiement()).'
'.$langs->trans('CurrentSituationTotal').''; - $i = 0; - foreach ($current_situation_counter as $sit) { - $curSign = $sit > 0 ? '+' : '-'; - $curType = $sit > 0 ? $langs->trans('situationInvoiceShortcode_S') : $langs->trans('situationInvoiceShortcode_AS'); - if ($i > 0) { - print ' '.$curSign.' '; - } - print $curType.abs($sit); - $i++; - } + // Payment mode + print '
'; + print ''; - if (isModEnabled("banque")) { - print ''; + if ($action != 'editmode' && $usercancreate) { + print ''; } - print ''; - print ''; - print ''; - print ''; + print '
'; + print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'), 1).''.price($total_global_ht).''.price($total_global_ttc).' 
'; + print '
'; + if ($action == 'editmode') { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1); + } else { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none', 'CRDT'); + } + print '
'; + print ''; + if ($usercancreate && $action != 'editmulticurrencycode' && $object->status == $object::STATUS_DRAFT) { + print ''; + } + print '
'; + print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print '
'; + $htmlname = (($usercancreate && $action == 'editmulticurrencycode') ? 'multicurrency_code' : 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname); + print '
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$next_invoice->getNomUrl(1).''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$next_invoice->situation_counter.'
'; + print ''; + if ($usercancreate && $action != 'editmulticurrencyrate' && $object->status == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print ''; } - print ''; - print ''; - print ''; - print ''; + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaid).'
'; + print '
'; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + 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, ($usercancreate ? 'multicurrency_tx' : 'none'), $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 ''; + } + print '
'; + print $langs->trans('BankAccount'); + print ''; + if (($action != 'editbankaccount') && $usercancreate) { + 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 "
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($usercancreate) { + print ''.img_edit().''; + } else { + print ' '; + } + print '
'; + print '
'; + if ($action != 'editincoterm') { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } else { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } + print '
'; + print ''; + if ($action != 'editretainedwarranty' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { + print ''; + } - print ''; - print ''; + print '
'; + print $langs->trans('RetainedWarranty'); + print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; + print '
'; + if ($action == 'editretainedwarranty' && $object->statut == Facture::STATUS_DRAFT) { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + } else { + print price($object->retained_warranty).'%'; + } + print '
'; + print ''; + if ($action != 'editretainedwarrantypaymentterms' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { + print ''; + } + + print '
'; + print $langs->trans('PaymentConditionsShortRetainedWarranty'); + print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; + print '
'; + $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); + if ($object->date > $defaultDate) { + $defaultDate = $object->date; + } + + if ($action == 'editretainedwarrantypaymentterms' && $object->statut == Facture::STATUS_DRAFT) { + //date('Y-m-d',$object->date_lim_reglement) + print '
'; + print ''; + print ''; + print ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + print $form->getSelectConditionsPaiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); + print ''; + print '
'; + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); + if (!$displayWarranty) { + print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); + } + } + print '
'; + print ''; + if ($action != 'editretainedwarrantydatelimit' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { + print ''; + } + + print '
'; + print $langs->trans('RetainedWarrantyDateLimit'); + print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).'
'; + print '
'; + $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); + if ($object->date > $defaultDate) { + $defaultDate = $object->date; + } + + if ($action == 'editretainedwarrantydatelimit' && $object->statut == Facture::STATUS_DRAFT) { + //date('Y-m-d',$object->date_lim_reglement) + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + } else { + print dol_print_date($object->retained_warranty_date_limit, 'day'); + } + print '
'; + + print '
'; + print '
'; + + print ''."\n"; + print '
'."\n"; + + print ''; + + $sign = 1; + if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) { + $sign = -1; // We invert sign for output + } + print ''; + // Amount HT + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount HT + print ''; + } + print ''; + + print ''; + // Amount VAT + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount VAT + print ''; + } + print ''; + + // Amount Local Taxes + if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(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" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { + print ''; + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + print ''; + } + print ''; + } + } + + + // Add the revenue stamp + if ($selleruserevenustamp) { + print ''; + } + + print ''; + // Amount TTC + print ''; + print ''; + if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { + // Multicurrency Amount TTC + print ''; + } + print ''; + + print '
' . $langs->trans('AmountHT') . '' . price($sign * $object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountVAT') . '' . price($sign * $object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + print ''; + if ($action != 'editrevenuestamp' && $object->status == $object::STATUS_DRAFT && $usercancreate) { + print ''; + } + print '
'; + print $langs->trans('RevenueStamp'); + print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
'; + print '
'; + if ($action == 'editrevenuestamp') { + print '
'; + print ''; + print ''; + print ''; + print ''; + print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code); + print ' → '; + print ' '; + print '
'; + print " "; + } else { + print price($object->revenuestamp, 1, '', 1, -1, -1, $conf->currency); + } + print '
' . $langs->trans('AmountTTC') . '' . price($sign * $object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . '' . price($sign * $object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + + $nbrows = 8; + $nbcols = 3; + if (isModEnabled('project')) { + $nbrows++; + } + if (isModEnabled("banque")) { + $nbrows++; + $nbcols++; + } + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { + $nbrows++; + } + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { + $nbrows++; + } + if ($selleruserevenustamp) { + $nbrows++; + } + if (isModEnabled('multicurrency')) { + $nbrows += 5; + } + if (isModEnabled('incoterm')) { + $nbrows += 1; + } + + // List of previous situation invoices + if (($object->situation_cycle_ref > 0) && !empty($conf->global->INVOICE_USE_SITUATION)) { + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; if (isModEnabled("banque")) { print ''; } + print ''; + print ''; + print ''; + print ''; + + $total_prev_ht = $total_prev_ttc = 0; + $total_global_ht = $total_global_ttc = 0; + + if (count($object->tab_previous_situation_invoice) > 0) { + // List of previous invoices + + $current_situation_counter = array(); + foreach ($object->tab_previous_situation_invoice as $prev_invoice) { + $tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement(); + $total_prev_ht += $prev_invoice->total_ht; + $total_prev_ttc += $prev_invoice->total_ttc; + $current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $prev_invoice->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (isModEnabled("banque")) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + } + } + + + $total_global_ht += $total_prev_ht; + $total_global_ttc += $total_prev_ttc; + $total_global_ht += $object->total_ht; + $total_global_ttc += $object->total_ttc; + $current_situation_counter[] = (($object->type == Facture::TYPE_CREDIT_NOTE) ?-1 : 1) * $object->situation_counter; + print ''; + print ''; + print ''; + print ''; + if (isModEnabled("banque")) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + + + print ''; + print ''; + print ''; + if (isModEnabled("banque")) { + print ''; + } print ''; print ''; print ''; print ''; + + + if (count($object->tab_next_situation_invoice) > 0) { + // List of next invoices + /*print ''; + print ''; + print ''; + print ''; + if (isModEnabled('banque')) print ''; + print ''; + print ''; + print ''; + print '';*/ + + $total_next_ht = $total_next_ttc = 0; + + foreach ($object->tab_next_situation_invoice as $next_invoice) { + $totalpaid = $next_invoice->getSommePaiement(); + $total_next_ht += $next_invoice->total_ht; + $total_next_ttc += $next_invoice->total_ttc; + + print ''; + print ''; + print ''; + print ''; + if (isModEnabled("banque")) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + } + + $total_global_ht += $total_next_ht; + $total_global_ttc += $total_next_ttc; + + print ''; + print ''; + if (isModEnabled("banque")) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + } + + print '
'.$langs->trans('ListOfSituationInvoices').''.$langs->trans('Situation').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').' 
'.$prev_invoice->getNomUrl(1).''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$prev_invoice->situation_counter.''.price($prev_invoice->total_ht).''.price($prev_invoice->total_ttc).''.$prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice).'
'.$object->getNomUrl(1).''.(($object->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$object->situation_counter.''.price($object->total_ht).''.price($object->total_ttc).''.$object->getLibStatut(3, $object->getSommePaiement()).'
'.$langs->trans('CurrentSituationTotal').''; + $i = 0; + foreach ($current_situation_counter as $sit) { + $curSign = $sit > 0 ? '+' : '-'; + $curType = $sit > 0 ? $langs->trans('situationInvoiceShortcode_S') : $langs->trans('situationInvoiceShortcode_AS'); + if ($i > 0) { + print ' '.$curSign.' '; + } + print $curType.abs($sit); + $i++; + } + print ''.price($total_global_ht).''.price($total_global_ttc).' 
' . $langs->trans('ListOfNextSituationInvoices') . '' . $langs->trans('AmountHT') . '' . $langs->trans('AmountTTC') . ' 
'.$next_invoice->getNomUrl(1).''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$next_invoice->situation_counter.''.price($next_invoice->total_ht).''.price($next_invoice->total_ttc).''.$next_invoice->getLibStatut(3, $totalpaid).'
'.price($total_global_ht).''.price($total_global_ttc).' 
'; } - print '
'; - } + $sign = 1; + if ($object->type == $object::TYPE_CREDIT_NOTE) { + $sign = -1; + } - $sign = 1; - if ($object->type == $object::TYPE_CREDIT_NOTE) { - $sign = -1; - } + // List of payments already done - // List of payments already done + print ''; + print '
'; + print ''; - print ''; - print '
'; - print '
'; + print ''; + print ''; + print ''; + print ''; + if (isModEnabled("banque")) { + print ''; + } + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - if (isModEnabled("banque")) { - print ''; - } - print ''; - print ''; - print ''; + // Payments already done (from payment on this invoice) + $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,'; + $sql .= ' c.code as payment_code, c.libelle as payment_label,'; + $sql .= ' pf.amount,'; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal, ba.currency_code as bacurrency_code'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= ' WHERE pf.fk_facture = '.((int) $object->id).' AND pf.fk_paiement = p.rowid'; + $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; + $sql .= ' ORDER BY p.datep, p.tms'; - // Payments already done (from payment on this invoice) - $sql = 'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,'; - $sql .= ' c.code as payment_code, c.libelle as payment_label,'; - $sql .= ' pf.amount,'; - $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal, ba.currency_code as bacurrency_code'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql .= ' WHERE pf.fk_facture = '.((int) $object->id).' AND pf.fk_paiement = p.rowid'; - $sql .= ' AND p.entity IN ('.getEntity('invoice').')'; - $sql .= ' ORDER BY p.datep, p.tms'; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + $i = 0; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; + if ($num > 0) { + while ($i < $num) { + $objp = $db->fetch_object($result); - if ($num > 0) { - while ($i < $num) { - $objp = $db->fetch_object($result); + $paymentstatic->id = $objp->rowid; + $paymentstatic->datepaye = $db->jdate($objp->dp); + $paymentstatic->ref = $objp->ref; + $paymentstatic->num_payment = $objp->num_payment; + $paymentstatic->paiementcode = $objp->payment_code; - $paymentstatic->id = $objp->rowid; - $paymentstatic->datepaye = $db->jdate($objp->dp); - $paymentstatic->ref = $objp->ref; - $paymentstatic->num_payment = $objp->num_payment; - $paymentstatic->paiementcode = $objp->payment_code; - - print ''; - print ''; - $label = ($langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code)) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label; - print ''; - if (isModEnabled("banque")) { - $bankaccountstatic->id = $objp->baid; - $bankaccountstatic->ref = $objp->baref; - $bankaccountstatic->label = $objp->baref; - $bankaccountstatic->number = $objp->banumber; - $bankaccountstatic->currency_code = $objp->bacurrency_code; - - if (isModEnabled('accounting')) { - $bankaccountstatic->account_number = $objp->account_number; - - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->fk_accountancy_journal); - $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } - - print ''; + print ''; - } - print ''; - print ''; - print ''; - $i++; - } - } + $label = ($langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code)) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label; + print ''; + if (isModEnabled("banque")) { + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; + $bankaccountstatic->number = $objp->banumber; + $bankaccountstatic->currency_code = $objp->bacurrency_code; - $db->free($result); - } else { - dol_print_error($db); - } + if (isModEnabled('accounting')) { + $bankaccountstatic->account_number = $objp->account_number; - if ($object->type != Facture::TYPE_CREDIT_NOTE) { - // Total already paid - print ''; + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); + $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } - $resteapayeraffiche = $resteapayer; - $cssforamountpaymentcomplete = 'amountpaymentcomplete'; - - // Loop on each credit note or deposit amount applied - $creditnoteamount = 0; - $depositamount = 0; - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; - $sql .= " re.description, re.fk_facture_source"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; - $sql .= " WHERE fk_facture = ".((int) $object->id); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - $invoice = new Facture($db); - while ($i < $num) { - $obj = $db->fetch_object($resql); - $invoice->fetch($obj->fk_facture_source); - print ''; - print ''; - print ''; - $i++; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { - $creditnoteamount += $obj->amount_ttc; - } - if ($invoice->type == Facture::TYPE_DEPOSIT) { - $depositamount += $obj->amount_ttc; + print ''; + } + print ''; + print ''; + print ''; + $i++; } } + + $db->free($result); } else { dol_print_error($db); } - // Partially paid 'discount' - if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { - print ''; - $resteapayeraffiche = 0; - $cssforamountpaymentcomplete = 'amountpaymentneutral'; - } - // Partially paid or abandoned 'badcustomer' - if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') { - print ''; - // $resteapayeraffiche=0; - $cssforamountpaymentcomplete = 'amountpaymentneutral'; - } - // Partially paid or abandoned 'product_returned' - if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') { - print ''; - $resteapayeraffiche = 0; - $cssforamountpaymentcomplete = 'amountpaymentneutral'; - } - // Partially paid or abandoned 'abandoned' - if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'abandon') { - print ''; - $resteapayeraffiche = 0; - $cssforamountpaymentcomplete = 'amountpaymentneutral'; - } - - // Billed - print ''; - // Remainder to pay - print ''; - print ''; - - // Remainder to pay Multicurrency - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + if ($object->type != Facture::TYPE_CREDIT_NOTE) { + // Total already paid print ''; + + $resteapayeraffiche = $resteapayer; + $cssforamountpaymentcomplete = 'amountpaymentcomplete'; + + // Loop on each credit note or deposit amount applied + $creditnoteamount = 0; + $depositamount = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; + $sql .= " WHERE fk_facture = ".((int) $object->id); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + $invoice = new Facture($db); + while ($i < $num) { + $obj = $db->fetch_object($resql); + $invoice->fetch($obj->fk_facture_source); + print ''; + print ''; + print ''; + $i++; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { + $creditnoteamount += $obj->amount_ttc; + } + if ($invoice->type == Facture::TYPE_DEPOSIT) { + $depositamount += $obj->amount_ttc; + } + } + } else { + dol_print_error($db); + } + + // Partially paid 'discount' + if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { + print ''; + $resteapayeraffiche = 0; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; + } + // Partially paid or abandoned 'badcustomer' + if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') { + print ''; + // $resteapayeraffiche=0; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; + } + // Partially paid or abandoned 'product_returned' + if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') { + print ''; + $resteapayeraffiche = 0; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; + } + // Partially paid or abandoned 'abandoned' + if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'abandon') { + print ''; + $resteapayeraffiche = 0; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; + } + + // Billed + print ''; + // Remainder to pay + print ''; - print ''; - } + print ''; - // Retained warranty : usualy use on construction industry - if (!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty) { - // Billed - retained warranty - if ($object->type == Facture::TYPE_SITUATION) { - $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100; - } else { - // Because one day retained warranty could be used on standard invoices - $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; + // Remainder to pay Multicurrency + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + print ''; + print ''; } - $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; + // Retained warranty : usualy use on construction industry + if (!empty($object->situation_final) && !empty($object->retained_warranty) && $displayWarranty) { + // Billed - retained warranty + if ($object->type == Facture::TYPE_SITUATION) { + $retainedWarranty = $total_global_ttc * $object->retained_warranty / 100; + } else { + // Because one day retained warranty could be used on standard invoices + $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100; + } - print ''; + $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty; - // retained warranty - print ''; - } - } else { // Credit note - $resteapayeraffiche = $resteapayer; - $cssforamountpaymentcomplete = 'amountpaymentneutral'; + print ''; - // Total already paid back - print ''; + // retained warranty + print ''; + } + } else { // Credit note + $resteapayeraffiche = $resteapayer; + $cssforamountpaymentcomplete = 'amountpaymentneutral'; - // Billed - print ''; - - // Remainder to pay back - print ''; - print ''; - print ''; - - // Remainder to pay back Multicurrency - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + // Total already paid back print ''; + + // Billed + print ''; + + // Remainder to pay back + print ''; - print ''; - } + print ''; + print ''; + print ''; - // Sold credit note - // print ''; - // print ''; - } - - print '
'.($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'.($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'; - print $paymentstatic->getNomUrl(1); - print ''; - $dateofpayment = $db->jdate($objp->dp); - $tmparray = dol_getdate($dateofpayment); - if ($tmparray['seconds'] == 0 && $tmparray['minutes'] == 0 && ($tmparray['hours'] == 0 || $tmparray['hours'] == 12)) { // We set hours to 0:00 or 12:00 because we don't know it - print dol_print_date($dateofpayment, 'day'); - } else { // Hours was set to real date of payment (special case for POS for example) - print dol_print_date($dateofpayment, 'dayhour', 'tzuser'); - } - print ''.dol_escape_htmltag($label.' '.$objp->num_payment).''; - if ($bankaccountstatic->id) { - print $bankaccountstatic->getNomUrl(1, 'transactions'); + print '
'; + print $paymentstatic->getNomUrl(1); + print ''; + $dateofpayment = $db->jdate($objp->dp); + $tmparray = dol_getdate($dateofpayment); + if ($tmparray['seconds'] == 0 && $tmparray['minutes'] == 0 && ($tmparray['hours'] == 0 || $tmparray['hours'] == 12)) { // We set hours to 0:00 or 12:00 because we don't know it + print dol_print_date($dateofpayment, 'day'); + } else { // Hours was set to real date of payment (special case for POS for example) + print dol_print_date($dateofpayment, 'dayhour', 'tzuser'); } print ''.price($sign * $objp->amount).''; - if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { - print 'rowid.'">'; - print img_delete(); - print ''; - } - print '
'.dol_escape_htmltag($label.' '.$objp->num_payment).'
'; - print ''; - if ($object->type != Facture::TYPE_DEPOSIT) { - print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - } else { - print $langs->trans('AlreadyPaid'); - } - print ''.price($totalpaid).' 
'; - print ''; - if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { - print $langs->trans("CreditNote").' '; - } - if ($invoice->type == Facture::TYPE_DEPOSIT) { - print $langs->trans("Deposit").' '; - } - print $invoice->getNomUrl(0); - print ''; - print ''.price($obj->amount_ttc).''; - print 'rowid.'">'; - print img_picto($langs->transnoentitiesnoconv("RemoveDiscount"), 'unlink'); - print ''; - print '
'; + if ($bankaccountstatic->id) { + print $bankaccountstatic->getNomUrl(1, 'transactions'); + } + print ''.price($sign * $objp->amount).''; + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $user->socid == 0) { + print 'rowid.'">'; + print img_delete(); + print ''; + } + print '
'; - print ''; - print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); - print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; - print ''; - print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); - print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; - print ''; - print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); - print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; - $text = $langs->trans("HelpAbandonOther"); - if ($object->close_note) { - $text .= '

'.$langs->trans("Reason").':'.$object->close_note; - } - print ''; - print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); - print ''; - print '
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; - print ''; - print $langs->trans("Billed"); - print ''.price($object->total_ttc).' 
'; - print ''; - print $langs->trans('RemainderToPay'); - if ($resteapayeraffiche < 0) { - print ' ('.$langs->trans('NegativeIfExcessReceived').')'; - } - print ''; - print ''.price($resteapayeraffiche).' 
'; print ''; - print $langs->trans('RemainderToPayMulticurrency'); + if ($object->type != Facture::TYPE_DEPOSIT) { + print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); + } else { + print $langs->trans('AlreadyPaid'); + } + print ''.price($totalpaid).' 
'; + print ''; + if ($invoice->type == Facture::TYPE_CREDIT_NOTE) { + print $langs->trans("CreditNote").' '; + } + if ($invoice->type == Facture::TYPE_DEPOSIT) { + print $langs->trans("Deposit").' '; + } + print $invoice->getNomUrl(0); + print ''; + print ''.price($obj->amount_ttc).''; + print 'rowid.'">'; + print img_picto($langs->transnoentitiesnoconv("RemoveDiscount"), 'unlink'); + print ''; + print '
'; + print ''; + print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); + print ''; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; + print ''; + print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; + print ''; + print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); + print ''; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; + $text = $langs->trans("HelpAbandonOther"); + if ($object->close_note) { + $text .= '

'.$langs->trans("Reason").':'.$object->close_note; + } + print ''; + print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); + print ''; + print '
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' 
'; + print ''; + print $langs->trans("Billed"); + print ''.price($object->total_ttc).' 
'; + print ''; + print $langs->trans('RemainderToPay'); if ($resteapayeraffiche < 0) { print ' ('.$langs->trans('NegativeIfExcessReceived').')'; } print ''; print ''; - //print (empty($object->multicurrency_code) ? $conf->currency : $object->multicurrency_code).' '; - print price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT'), 1, $langs, 1, -1, -1, (empty($object->multicurrency_code) ? $conf->currency : $object->multicurrency_code)).' 
'.price($resteapayeraffiche).' 
'; + print ''; + print $langs->trans('RemainderToPayMulticurrency'); + if ($resteapayeraffiche < 0) { + print ' ('.$langs->trans('NegativeIfExcessReceived').')'; + } + print ''; + print ''; + //print (empty($object->multicurrency_code) ? $conf->currency : $object->multicurrency_code).' '; + print price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT'), 1, $langs, 1, -1, -1, (empty($object->multicurrency_code) ? $conf->currency : $object->multicurrency_code)).' 
'.$langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')).' :'.price($billedWithRetainedWarranty).' 
'; - print $langs->trans("RetainedWarranty").' ('.$object->retained_warranty.'%)'; - print !empty($object->retained_warranty_date_limit) ? ' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; - print ' :'.price($retainedWarranty).' 
'.$langs->trans("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')).' :'.price($billedWithRetainedWarranty).' 
'; - print ''.$langs->trans('AlreadyPaidBack').''; - print ''.price($sign * $totalpaid).' 
'; + print $langs->trans("RetainedWarranty").' ('.$object->retained_warranty.'%)'; + print !empty($object->retained_warranty_date_limit) ? ' '.$langs->trans("ToPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : ''; + print ' :'.price($retainedWarranty).' 
'.$langs->trans("Billed").''.price($sign * $object->total_ttc).' 
'; - print ''.$langs->trans('RemainderToPayBack'); - if ($resteapayeraffiche > 0) { - print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; - } - print ''.price($sign * $resteapayeraffiche).' 
'; - print ''.$langs->trans('RemainderToPayBackMulticurrency'); + print ''.$langs->trans('AlreadyPaidBack').''; + print ''.price($sign * $totalpaid).' 
'.$langs->trans("Billed").''.price($sign * $object->total_ttc).' 
'; + print ''.$langs->trans('RemainderToPayBack'); if ($resteapayeraffiche > 0) { print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } - print ''; - print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($sign * $object->multicurrency_tx * $resteapayeraffiche, 'MT')).' 
'.price($sign * $resteapayeraffiche).' 
'.$langs->trans('TotalTTC').' :'.price($sign * - // $object->total_ttc).' 
'; - print '
'; - - // 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'; - } - - // Get object lines - $result = $object->getLinesArray(); - - // Add products/services form - //$forceall = 1; - global $inputalsopricewithtax; - $inputalsopricewithtax = 1; - - // Show global modifiers for situation invoices - if (!empty($conf->global->INVOICE_USE_SITUATION)) { - if ($object->situation_cycle_ref && $object->statut == 0) { - print ''."\n"; - print '
'; - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print ''; - - print ''; - - // Adds a line numbering column - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + // Remainder to pay back Multicurrency + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { + print ''; + print ''; } - print ''; - print ''; - print ''; - print "\n"; - print ''; - // Adds a line numbering column - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + // Sold credit note + // print ''; + // print ''; + } + + print '
 
'; + print ''.$langs->trans('RemainderToPayBackMulticurrency'); + if ($resteapayeraffiche > 0) { + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; + } + print ''; + print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($sign * $object->multicurrency_tx * $resteapayeraffiche, 'MT')).' 
'.$langs->trans('ModifyAllLines').''.$langs->trans('Progress').' 
 
'.$langs->trans('TotalTTC').' :'.price($sign * + // $object->total_ttc).' 
'; + print '
'; + + // 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'; + } + + // Get object lines + $result = $object->getLinesArray(); + + // Add products/services form + //$forceall = 1; + global $inputalsopricewithtax; + $inputalsopricewithtax = 1; + + // Show global modifiers for situation invoices + if (!empty($conf->global->INVOICE_USE_SITUATION)) { + if ($object->situation_cycle_ref && $object->statut == 0) { + print ''."\n"; + print '
'; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + + // Adds a line numbering column + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; + print ''; + print ''; + print "\n"; + + print ''; + // Adds a line numbering column + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + + print '
 '.$langs->trans('ModifyAllLines').''.$langs->trans('Progress').' 
  %
'; + + print ''; + + print '
'; } - print '
 %
'; - - print ''; - - print '
'; } - } - print '
- - - - - - - '; + print ' + + + + + + + '; - if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - print ''; - - // Show object lines - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); - } - - // Form to add new line - if ($object->statut == 0 && $usercancreate && $action != 'valid') { - if ($action != 'editline' && $action != 'selectlines') { - // Add free products/services - - $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->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } + + print '
'; + print '
'; + + // Show object lines + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + } + + // Form to add new line + if ($object->statut == 0 && $usercancreate && $action != 'valid') { + if ($action != 'editline' && $action != 'selectlines') { + // Add free products/services + + $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 + } + } + + print "
\n"; + print "
"; + + print "
\n"; } - - print "
\n"; - print ""; - - print "\n"; - print dol_get_fiche_end(); From d2355e91e996d3ce25a7d3b04dbe4494ae262eef Mon Sep 17 00:00:00 2001 From: jyhere Date: Tue, 31 Oct 2023 06:57:25 -0400 Subject: [PATCH 3/5] NEW: add a $notrigger param to Product::updatePrice() method (#26404) * NEW: add a $notrigger param to Product::updatePrice() method * Update product.class.php --------- Co-authored-by: Laurent Destailleur --- htdocs/product/class/product.class.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 990cd808c7f..4e2407e5ded 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2209,9 +2209,10 @@ class Product extends CommonObject * @param int $ignore_autogen Used to avoid infinite loops * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param string $newdefaultvatcode Default vat code + * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '') + public function updatePrice($newprice, $newpricebase, $user, $newvat = '', $newminprice = 0, $level = 0, $newnpr = 0, $newpbq = 0, $ignore_autogen = 0, $localtaxes_array = array(), $newdefaultvatcode = '', $notrigger = 0) { global $conf, $langs; @@ -2380,10 +2381,12 @@ class Product extends CommonObject $this->level = $level; // Store level of price edited for trigger // Call trigger - $result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; + if (!$notrigger) { + $result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } } // End call triggers @@ -5825,8 +5828,8 @@ class Product extends CommonObject $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); if ($reshook > 0) { $this->stock_theorique = $hookmanager->resArray['stock_theorique']; - } elseif (isset($hookmanager->resArray['stock_stats_hook'])) { - $this->stock_theorique += $hookmanager->resArray['stock_stats_hook']; + } elseif ($reshook == 0 && isset($hookmanager->resArray['stock_stats_hook'])) { + $this->stock_theorique += $hookmanager->resArray['stock_stats_hook']; } return 1; From 1a32455e70474c64043d730eafaffa63254d43ae Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 31 Oct 2023 11:57:53 +0100 Subject: [PATCH 4/5] update comment and credentials (#26401) * update comment * update credentials * remove bad commit * update credentials --------- Co-authored-by: Christophe Battarel --- htdocs/commande/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 90d28f50418..9c539791cc5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2011-2023 Philippe Grand - * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2012-2023 Christophe Battarel * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry @@ -2451,7 +2451,8 @@ if ($action == 'create' && $usercancreate) { dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - // Call Hook OrderCard + + // Call Hook tabContentViewOrder $parameters = array(); // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('tabContentViewOrder', $parameters, $object, $action); From 7bcd6c2a3a96c3fcef0bb37ca85eff8e40554287 Mon Sep 17 00:00:00 2001 From: Florent Poinsaut <1256948+FlorentPoinsaut@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:59:07 +0100 Subject: [PATCH 5/5] FIX #25793 V18.0.1 : Cannot add time spent (#26405) --- htdocs/install/mysql/migration/17.0.0-18.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index b475c8702ce..a0bb45ae935 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -121,6 +121,8 @@ ALTER TABLE llx_bordereau_cheque ADD COLUMN type VARCHAR(6) DEFAULT 'CHQ'; -- Element time ALTER TABLE llx_projet_task_time RENAME TO llx_element_time; +-- VPGSQL8.2 ALTER SEQUENCE llx_projet_task_time_rowid_seq RENAME TO llx_element_time_rowid_seq; + -- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES'; -- VMYSQL4.1 update llx_element_time set task_date = NULL where DATE(STR_TO_DATE(task_date, '%Y-%m-%d')) IS NULL; -- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';