diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index ca6b2eadae1..935f0cf69c4 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -201,7 +201,18 @@ else if ($action == 'classin' && $user->rights->contrat->creer) else if ($action == 'addline' && $user->rights->contrat->creer) { - if (GETPOST('pqty') && ((GETPOST('pu') != '' && GETPOST('desc')) || GETPOST('idprod'))) + if (! GETPOST('qty')) + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")),'errors'); + $error++; + } + if ((GETPOST('price_ht') == '' || ! GETPOST('dp_desc')) && ! GETPOST('idprod')) + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")),'errors'); + $error++; + } + + if (! $error) { $ret=$object->fetch($id); if ($ret < 0) @@ -286,11 +297,11 @@ else if ($action == 'addline' && $user->rights->contrat->creer) } else { - $pu_ht=GETPOST('pu'); + $pu_ht=GETPOST('price_ht'); $price_base_type = 'HT'; $tva_tx=str_replace('*','',GETPOST('tva_tx')); $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0; - $desc=GETPOST('desc'); + $desc=GETPOST('dp_desc'); } $localtax1_tx=get_localtax($tva_tx,1,$object->societe); @@ -310,12 +321,12 @@ else if ($action == 'addline' && $user->rights->contrat->creer) $result = $object->addline( $desc, $pu_ht, - GETPOST('pqty'), + GETPOST('qty'), $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('idprod'), - GETPOST('premise'), + GETPOST('remise_percent'), $date_start, $date_end, $price_base_type, @@ -343,6 +354,14 @@ else if ($action == 'addline' && $user->rights->contrat->creer) contrat_pdf_create($db, $object->id, $object->modelpdf, $outputlangs); } */ + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['tva_tx']); + unset($_POST['dp_desc']); } else { @@ -372,7 +391,7 @@ else if ($action == 'updateligne' && $user->rights->contrat->creer && ! GETPOST( $localtax1_tx=get_localtax(GETPOST('eltva_tx'),1,$object->thirdparty); $localtax2_tx=get_localtax(GETPOST('eltva_tx'),2,$object->thirdparty); - $objectline->description=GETPOST('eldesc'); + $objectline->description=GETPOST('product_desc'); $objectline->price_ht=GETPOST('elprice'); $objectline->subprice=GETPOST('elprice'); $objectline->qty=GETPOST('elqty'); @@ -898,7 +917,7 @@ else } else { - print "".nl2br($objp->description)."\n"; + print "".dol_htmlentitiesbr($objp->description)."\n"; } // TVA print ''.vatrate($objp->tva_tx,'%',$objp->info_bits).''; @@ -997,7 +1016,16 @@ else { print $objp->label?$objp->label.'
':''; } - print ''; + + // editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); + $doleditor=new DolEditor('product_desc',$objp->description,'',92,'dolibarr_details','',false,true,$enable,$nbrows,70); + $doleditor->Create(); + + print ''; print ''; print $form->load_tva("eltva_tx",$objp->tva_tx,$mysoc,$object->thirdparty); print ''; @@ -1252,108 +1280,60 @@ else } print ''; - /* - * Ajouter une ligne produit/service - */ + // Form to add new line if ($user->rights->contrat->creer && ($object->statut >= 0)) { + $dateSelector=1; + print '
'; - print ''; // Array with (n*2)+1 lines + print '
'; // Array with (n*2)+1 lines - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $var=false; - - // Service sur produit predefini - print ''; - print ''; - print ''; - print ''; - print ''; - - print ""; - print ''; - - print ''; - print ''; - print ''; - print ''."\n"; - - print ""; - print ''; - print ''; - - print ''; - - $var=!$var; - - // Service libre - print ''; - print ''; - print ''; - print ''; - print ''; - - print ""; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''."\n"; - - print ""; - print ''; - print ''; + // Trick to not show product entries + $savproductenabled=$conf->product->enabled; + $conf->product->enabled = 0; + // Form to add new line + if ($action != 'editline') + { + $var=true; + + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + // Add free or predefined products/services + $object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + } + else + { + // Add free products/services + $object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + + // Add predefined products/services + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + $var=!$var; + $object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty,$hookmanager); + } + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + + // Restore correct setup + $conf->product->enabled = $savproductenabled; + print ''; print '
'.$langs->trans("Service").''.$langs->trans("VAT").''.$langs->trans("PriceUHT").''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'  
'; - // multiprix - if (! empty($conf->global->PRODUIT_MULTIPRICES)) - $form->select_produits('','idprod',1,$conf->product->limit_size,$object->thirdparty->price_level); - else - $form->select_produits('','idprod',1,$conf->product->limit_size); - print '
'; - print ''; - print '
%
'; - print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start",$usehm,$usehm,1,"addline"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end",$usehm,$usehm,1,"addline"); - print '
'; - print $form->load_tva("tva_tx",-1,$mysoc,$object->thirdparty); - print '%
'; - print $langs->trans("DateStartPlanned").' '; - $form->select_date('',"date_start_sl",$usehm,$usehm,1,"addline_sl"); - print '   '.$langs->trans("DateEndPlanned").' '; - $form->select_date('',"date_end_sl",$usehm,$usehm,1,"addline_sl"); - print '
'; } - - //print ''; - - //print ''; - print ''; - /************************************************************* - * Boutons Actions - *************************************************************/ + /* + * Buttons + */ if ($user->societe_id == 0) { @@ -1391,6 +1371,10 @@ else { print ''.$langs->trans("Delete").''; } + else + { + print ''.$langs->trans("Delete").''; + } print ""; print '
'; @@ -1410,5 +1394,6 @@ else llxFooter(); + $db->close(); ?> diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 5b611768119..f2a621f7047 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -23,6 +23,10 @@ * $this (invoice, order, ...) * $line defined */ + +$usemargins=0; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; + ?> @@ -37,23 +41,23 @@ trans('ReductionShort'); ?> margin->enabled)) { + if (! empty($usemargins)) + { ?> - trans('BuyingPrice'); ?> -global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; + trans('BuyingPrice'); ?> + global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; } -?> + ?>  
" /> - - + + + + > global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> @@ -92,40 +96,49 @@ % margin->enabled)) { - ?> + if (! empty($usemargins)) + { + ?> "> - global->DISPLAY_MARGIN_RATES)) - $colspan++; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - $colspan++; + global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; } ?> - service->enabled) && $dateSelector) { - if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - $colspan = 10; - else - $colspan = 9; - if (! empty($conf->margin->enabled)) { + service->enabled) && $dateSelector) + { + if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; + else $colspan = 9; + + if (! empty($usemargins)) + { $colspan++; // For the buying price - if($conf->global->DISPLAY_MARGIN_RATES) - $colspan++; - if($conf->global->DISPLAY_MARK_RATES) - $colspan++; + if($conf->global->DISPLAY_MARGIN_RATES) $colspan++; + if($conf->global->DISPLAY_MARK_RATES) $colspan++; } - ?> + ?> > trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date('','date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct"); + if (! empty($object->element) && $object->element == 'contrat') + { + print $langs->trans("DateStartPlanned").' '; + $form->select_date('',"date_start_sl",$usehm,$usehm,1,"addline_sl"); + print '   '.$langs->trans("DateEndPlanned").' '; + $form->select_date('',"date_end_sl",$usehm,$usehm,1,"addline_sl"); + } + else + { + echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + echo $form->select_date('','date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date('','date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct"); + } ?> diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index 6897a523b56..17b438640e8 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -24,6 +24,10 @@ * $this (invoice, order, ...) * $line defined */ + +$usemargins=0; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; + ?> @@ -42,22 +46,23 @@ trans('ReductionShort'); ?> margin->enabled)) +if (! empty($usemargins)) { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; -?> + ?> trans('BuyingPrice'); ?> -   " /> - - + + + + +