From eb1fdca157ebbe800e8d580134e5e4e29a80d202 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Oct 2017 10:44:18 +0200 Subject: [PATCH] NEW Can create intervention from a proposal --- htdocs/comm/action/class/actioncomm.class.php | 8 +-- htdocs/comm/propal/card.php | 8 +++ htdocs/commande/card.php | 2 + htdocs/core/class/commonobject.class.php | 20 +++--- htdocs/core/class/html.form.class.php | 4 ++ htdocs/core/tpl/originproductline.tpl.php | 6 +- htdocs/fichinter/card.php | 71 ++++++++++++++----- 7 files changed, 85 insertions(+), 34 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 12c11f863f1..cf380871926 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -907,7 +907,7 @@ class ActionComm extends CommonObject return $db->lasterror(); } } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -918,7 +918,7 @@ class ActionComm extends CommonObject function load_board($user, $load_state_board=0) { global $conf, $langs; - + if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp"; else { $this->nb=array(); @@ -934,7 +934,7 @@ class ActionComm extends CommonObject if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")"; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -956,7 +956,7 @@ class ActionComm extends CommonObject if ($agenda_static->hasDelay()) $response->nbtodolate++; } else $this->nb["actionscomm"]=$obj->nb; } - + $this->db->free($resql); if(empty($load_state_board)) return $response; else return 1; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 35767c16167..48756a8828c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2284,6 +2284,14 @@ if ($action == 'create') } } + // Create an intervention + if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { + if ($user->rights->ficheinter->creer) { + $langs->load("interventions"); + print '
' . $langs->trans("AddIntervention") . '
'; + } + } + // Create contract if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) { $langs->load("contracts"); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c385fe9a6ae..c5d03f399f2 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1686,6 +1686,8 @@ if ($action == 'create' && $user->rights->commande->creer) } print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . ''; + + // Amount print '' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . ''; print '' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . ""; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3631a6509ee..df35201af24 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3648,11 +3648,12 @@ abstract class CommonObject * Return HTML table table of source object lines * TODO Move this and previous function into output html class file (htmlline.class.php). * If lines are into a template, title must also be into a template - * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. + * But for the moment we don't know if it's possible, so we keep the method available on overloaded objects. * + * @param string $restrictlist ''=All lines, 'services'=Restrict to services only * @return void */ - function printOriginLinesList() + function printOriginLinesList($restrictlist='') { global $langs, $hookmanager, $conf; @@ -3674,8 +3675,6 @@ abstract class CommonObject foreach ($this->lines as $line) { - - if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) { if (empty($line->fk_parent_line)) @@ -3687,7 +3686,7 @@ abstract class CommonObject } else { - $this->printOriginLine($line,$var); + $this->printOriginLine($line, $var, $restrictlist); } $i++; @@ -3700,11 +3699,12 @@ abstract class CommonObject * If lines are into a template, title must also be into a template * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param CommonObjectLine $line Line - * @param string $var Var + * @param CommonObjectLine $line Line + * @param string $var Var + * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @return void */ - function printOriginLine($line,$var) + function printOriginLine($line, $var, $restrictlist='') { global $langs, $conf; @@ -3806,6 +3806,10 @@ abstract class CommonObject if($conf->global->PRODUCT_USE_UNITS) $this->tpl['unit'] = $line->getLabelOfUnit('long'); $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; + // Is the line strike or not + $this->tpl['strike']=0; + if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1; + // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index faf26f7c111..389519d7b7f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4742,6 +4742,7 @@ class Form { $shour = dol_print_date($set_time, "%H"); $smin = dol_print_date($set_time, "%M"); + $ssec = dol_print_date($set_time, "%S"); } } else @@ -4752,6 +4753,7 @@ class Form $sday = ''; $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? '' : $conf->global->MAIN_DEFAULT_DATE_HOUR; $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN; + $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? '' : $conf->global->MAIN_DEFAULT_DATE_SEC; } // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' @@ -4932,6 +4934,8 @@ class Form $retstring.=''; } $retstring.=''; + + $retstring.=''; } // Add a "Now" link diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index c8cd6674a7a..2efc114cc1d 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -19,8 +19,8 @@ ?> -'; +tpl['strike'])?'':' strikefordisabled').'">'; print ''.$this->tpl['label'].''; print ''.$this->tpl['description'].''; print ''.$this->tpl['vat_rate'].''; @@ -29,7 +29,7 @@ if (!empty($conf->multicurrency->enabled)) print ''.$this->tpl['multicurrency_price'].''; print ''.$this->tpl['qty'].''; -if($conf->global->PRODUCT_USE_UNITS) +if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($this->tpl['unit']).''; print ''.$this->tpl['remise_percent'].''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 52c23f551d2..bc6fb9d3014 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -60,6 +60,7 @@ $ref = GETPOST('ref','alpha'); $socid = GETPOST('socid','int'); $contratid = GETPOST('contratid','int'); $action = GETPOST('action','alpha'); +$cancel = GETPOST('cancel','alpha'); $confirm = GETPOST('confirm','alpha'); $mesg = GETPOST('msg','alpha'); $origin=GETPOST('origin','alpha'); @@ -105,6 +106,16 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + $action=''; + } + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -201,11 +212,11 @@ if (empty($reshook)) else if ($action == 'add' && $user->rights->ficheinter->creer) { $object->socid = $socid; - $object->duration = GETPOST('duration','int'); + $object->duration = GETPOST('duration','int'); $object->fk_project = GETPOST('projectid','int'); $object->fk_contrat = GETPOST('contratid','int'); $object->author = $user->id; - $object->description = GETPOST('description'); + $object->description = GETPOST('description','none'); $object->ref = $ref; $object->modelpdf = GETPOST('model','alpha'); $object->note_private = GETPOST('note_private','none'); @@ -276,7 +287,7 @@ if (empty($reshook)) $fk_parent_line=0; $num=count($lines); - for ($i=0;$i<$num;$i++) + for ($i=0; $i<$num; $i++) { $product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT); @@ -829,7 +840,7 @@ if ($action == 'create') $soc=new Societe($db); - print load_fiche_titre($langs->trans("AddIntervention")); + print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial'); dol_htmloutput_mesg($mesg); @@ -1008,6 +1019,30 @@ if ($action == 'create') $newclassname=$classname; if ($newclassname=='Propal') $newclassname='CommercialProposal'; print ''.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).''; + + // Amount + /* Hide amount because we only copy services so amount may differ than source + print '' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . ''; + print '' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . ""; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE + { + print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . ""; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF + { + print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . ""; + } + + print '' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . ""; + + if (!empty($conf->multicurrency->enabled)) + { + print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; + print '' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; + print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + } + */ } print ''; @@ -1029,6 +1064,18 @@ if ($action == 'create') print ''; print ''; + + // Show origin lines + if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { + $title = $langs->trans('Services'); + print load_fiche_titre($title); + + print ''; + + $objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS)?'services':''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on + + print '
'; + } } else { @@ -1604,22 +1651,8 @@ else if ($id > 0 || ! empty($ref)) else print '
'.$langs->trans('SendByMail').'
'; } - // Event agenda - if (! empty($conf->global->FICHINTER_ADDLINK_TO_EVENT)) - { - if (! empty($conf->agenda->enabled) && $object->statut > Fichinter::STATUS_DRAFT) - { - $langs->load("agenda"); - if ($object->statut < Fichinter::STATUS_BILLED) - { - if ($user->rights->agenda->myactions->create) print '
'.$langs->trans("AddEvent").'
'; - else print '
'.$langs->trans("AddEvent").'
'; - } - } - } - // Proposal - if (! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) + if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED)