diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e2444501f7a..0ce3f369933 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1407,9 +1407,20 @@ if ($id > 0 || ! empty($ref)) */ print ''; + // Milestone module + if ($conf->milestone->enabled) + { + $milestone = new Milestone($db); + $milestoneListArray = $milestone->getObjectMilestonesArray($propal); + } + // Show lines $lines = $propal->getLinesArray(); - if (! empty($lines) ) print_lines($propal, $lines); + if (! empty($lines) ) + { + print_title_list(); + print_lines_list($propal, $lines); + } /* * Form to add new line diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php index 5f7e2260ec5..69366f8d67b 100644 --- a/htdocs/lib/propal.lib.php +++ b/htdocs/lib/propal.lib.php @@ -111,17 +111,13 @@ function propal_prepare_head($propal) } /** - * \brief Return HTML table with list of propal lines + * \brief Return HTML table with title list * \param propal Object propal * \param lines Array of propal lines */ -function print_lines($propal,$lines) +function print_title_list() { - global $db; - global $conf,$langs,$user; - global $html,$bc; - - $product_static = new Product($db); + global $conf,$langs; print ''; print ''; @@ -133,7 +129,15 @@ function print_lines($propal,$lines) print ''; print ''; print "\n"; - +} + +/** + * \brief Return HTML with proposal lines + * \param propal Object proposal + * \param lines Proposal lines + */ +function print_lines_list($propal,$lines) +{ $num = count($lines); $var = true; $i = 0; @@ -141,284 +145,300 @@ function print_lines($propal,$lines) foreach ($lines as $line) { $var=!$var; - - // Show product and description - $type=$line->product_type?$line->product_type:$line->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($line->date_start)) $type=1; - if (! empty($line->date_end)) $type=1; - - // Ligne en mode visu - if ($_GET['action'] != 'editline' || $_GET['lineid'] != $line->id) - { - print ''; - - // Produit - if ($line->fk_product > 0) - { - print ''; - } - else - { - print '\n"; - } - - if ($conf->global->PRODUIT_USE_MARKUP && $conf->use_javascript_ajax) - { - // TODO a déplacer dans classe module marge - $formMarkup = ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= '
'.$langs->trans('Description').''.$langs->trans('TotalHTShort').' 
'; - print ''; // ancre pour retourner sur la ligne; - - // Show product and description - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $product_static->libelle=$line->product_label; - $text=$product_static->getNomUrl(1); - $text.= ' - '.$line->product_label; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); - print $html->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($line->date_start, $line->date_end); - - // Add description in form - if ($conf->global->PRODUIT_DESC_IN_FORM) - { - print ($line->description && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; - } - - print '
'; - print ''; // ancre pour retourner sur la ligne - if (($line->info_bits & 2) == 2) - { - print ''; - print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); - print ''; - if ($line->description) - { - if ($line->description == '(CREDIT_NOTE)') - { - $discount=new DiscountAbsolute($db); - $discount->fetch($line->fk_remise_except); - print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } - else - { - print ' - '.nl2br($line->description); - } - } - } - else - { - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($line->description); - - // Show range - print_date_range($db->jdate($line->date_start),$db->jdate($line->date_end)); - } - print "
'."\n"; - if ($objp->fk_product > 0) - { - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - } - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - //$formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= ''."\n"; - $formMarkup.= '
 
 '.$langs->trans('SupplierPrice').''.$html->select_product_fourn_price($line->fk_product,'productfournpriceid').'
 
 '.$langs->trans('PurchasePrice').' '.$langs->trans('HT').'
 '.$langs->trans('MarkupRate').'
 '.$langs->trans('SellingPrice').' '.$langs->trans('HT').'
 '.$langs->trans('CashFlow').' '.$langs->trans('HT').'
'."\n"; - $formMarkup.= ''."\n"; - //$formMarkup.= '   '."\n"; - $formMarkup.= '
'."\n"; - $formMarkup.= ajax_updaterWithID("rate".$i,"markup","sellingprice_ht".$i,DOL_URL_ROOT."/product/ajaxproducts.php","&count=".$i,"working")."\n"; - - - print ''."\n"; - - print ''."\n"; - - print ''; - print ''; - print ''; - print '
'; - if (($objp->info_bits & 2) == 2) - { - // Ligne remise predefinie, on ne permet pas modif - } - else - { - $picto = ''; - $picto.= img_picto($langs->trans("Calculate"),'calc.png'); - $picto.= ''; - print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i); - } - print ''.vatrate($line->marge_tx).'%
'; - print ''; - } - - // VAT Rate - print ''.vatrate($line->tva_tx,'%',$line->info_bits).''; - - // U.P HT - print ''.price($line->subprice)."\n"; - - // Qty - print ''; - if ((($line->info_bits & 2) != 2) && $line->special_code != 3) - { - print $line->qty; - } - else print ' '; - print ''; - - // Remise percent (negative or positive) - if (!empty($line->remise_percent) && $line->special_code != 3) - { - print ''.dol_print_reduction($line->remise_percent,$langs)."\n"; - } - else - { - print ' '; - } - - // Montant total HT - if ($line->special_code == 3) - { - // Si ligne en option - print ''.$langs->trans('Option').''; - } - else - { - print ''.price($line->total_ht)."\n"; - } - - // Icone d'edition et suppression - if ($propal->statut == 0 && $user->rights->propale->creer) - { - print ''; - if (($line->info_bits & 2) == 2) - { - // Ligne remise predefinie, on permet pas modif - } - else - { - print 'id.'#'.$line->id.'">'; - print img_edit(); - print ''; - } - print ''; - print ''; - print 'id.'">'; - print img_delete(); - print ''; - if ($num > 1) - { - print ''; - if ($i > 0) - { - print 'id.'">'; - print img_up(); - print ''; - } - if ($i < $num-1) - { - print 'id.'">'; - print img_down(); - print ''; - } - print ''; - } - } - else - { - print ' '; - } - - print ''; - } - - // Ligne en mode update - if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["lineid"] == $line->id) - { - print '
id.'" method="POST">'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; // ancre pour retourner sur la ligne - if ($line->fk_product > 0) - { - print ''; - print ''; - if ($line->fk_product_type==1) print img_object($langs->trans('ShowService'),'service'); - else print img_object($langs->trans('ShowProduct'),'product'); - print ' '.$line->ref.''; - print ' - '.nl2br($line->product_label); - print '
'; - } - if ($_GET["action"] == 'editline') - { - // editeur wysiwyg - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$line->description,164,'dolibarr_details'); - $doleditor->Create(); - } - else - { - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - print ''; - } - } - print ''; - if ($conf->global->PRODUIT_USE_MARKUP) - { - print ''.vatrate($line->marge_tx).'%'; - } - print ''; - print $html->select_tva('tva_tx',$line->tva_tx,$mysoc,$societe,'',$line->info_bits); - print ''; - print ''; - print ''; - if (($line->info_bits & 2) != 2) - { - print ''; - } - else print ' '; - print ''; - print ''; - if (($line->info_bits & 2) != 2) - { - print '%'; - } - else print ' '; - print ''; - print ''; - print '
'; - print '' . "\n"; - - print "
\n"; - } + + print_line($propal,$line,$var,$num,$i); + $i++; } } +/** + * \brief Return HTML with selected proposal line + * \param propal Object proposal + * \param line Selected proposal line + */ +function print_line($propal,$line,$var=true,$num=0,$i=0) +{ + global $db; + global $conf,$langs,$user; + global $html,$bc; + + // Show product and description + $type=$line->product_type?$line->product_type:$line->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($line->date_start)) $type=1; + if (! empty($line->date_end)) $type=1; + + // Ligne en mode visu + if ($_GET['action'] != 'editline' || $_GET['lineid'] != $line->id) + { + print ''; + + // Produit + if ($line->fk_product > 0) + { + $product_static = new Product($db); + + print ''; + print ''; // ancre pour retourner sur la ligne; + + // Show product and description + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $product_static->libelle=$line->product_label; + $text=$product_static->getNomUrl(1); + $text.= ' - '.$line->product_label; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); + print $html->textwithtooltip($text,$description,3,'','',$i); + + // Show range + print_date_range($line->date_start, $line->date_end); + + // Add description in form + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($line->description && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; + } + + print ''; + } + else + { + print ''; + print ''; // ancre pour retourner sur la ligne + if (($line->info_bits & 2) == 2) + { + print ''; + print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); + print ''; + if ($line->description) + { + if ($line->description == '(CREDIT_NOTE)') + { + $discount=new DiscountAbsolute($db); + $discount->fetch($line->fk_remise_except); + print ' - '.$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + else + { + print ' - '.nl2br($line->description); + } + } + } + else + { + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.nl2br($line->description); + // Show range + print_date_range($line->date_start,$line->date_end); + } + print "\n"; + } + + if ($conf->global->PRODUIT_USE_MARKUP && $conf->use_javascript_ajax) + { + // TODO a déplacer dans classe module marge + $formMarkup = '
'."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + if ($objp->fk_product > 0) + { + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + } + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + //$formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= ''."\n"; + $formMarkup.= '
 
 '.$langs->trans('SupplierPrice').''.$html->select_product_fourn_price($line->fk_product,'productfournpriceid').'
 
 '.$langs->trans('PurchasePrice').' '.$langs->trans('HT').'
 '.$langs->trans('MarkupRate').'
 '.$langs->trans('SellingPrice').' '.$langs->trans('HT').'
 '.$langs->trans('CashFlow').' '.$langs->trans('HT').'
'."\n"; + $formMarkup.= ''."\n"; + //$formMarkup.= '   '."\n"; + $formMarkup.= '
'."\n"; + $formMarkup.= ajax_updaterWithID("rate".$i,"markup","sellingprice_ht".$i,DOL_URL_ROOT."/product/ajaxproducts.php","&count=".$i,"working")."\n"; + + + print ''."\n"; + + print ''."\n"; + + print ''; + print ''; + print ''; + print '
'; + if (($objp->info_bits & 2) == 2) + { + // Ligne remise predefinie, on ne permet pas modif + } + else + { + $picto = ''; + $picto.= img_picto($langs->trans("Calculate"),'calc.png'); + $picto.= ''; + print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i); + } + print ''.vatrate($line->marge_tx).'%
'; + print ''; + } + + // VAT Rate + print ''.vatrate($line->tva_tx,'%',$line->info_bits).''; + + // U.P HT + print ''.price($line->subprice)."\n"; + + // Qty + print ''; + if ((($line->info_bits & 2) != 2) && $line->special_code != 3) + { + print $line->qty; + } + else print ' '; + print ''; + + // Remise percent (negative or positive) + if (!empty($line->remise_percent) && $line->special_code != 3) + { + print ''.dol_print_reduction($line->remise_percent,$langs)."\n"; + } + else + { + print ' '; + } + + // Montant total HT + if ($line->special_code == 3) + { + // Si ligne en option + print ''.$langs->trans('Option').''; + } + else + { + print ''.price($line->total_ht)."\n"; + } + + // Icone d'edition et suppression + if ($propal->statut == 0 && $user->rights->propale->creer) + { + print ''; + if (($line->info_bits & 2) == 2) + { + // Ligne remise predefinie, on permet pas modif + } + else + { + print 'id.'#'.$line->id.'">'; + print img_edit(); + print ''; + } + print ''; + print ''; + print 'id.'">'; + print img_delete(); + print ''; + if ($num > 1) + { + print ''; + if ($i > 0) + { + print 'id.'">'; + print img_up(); + print ''; + } + if ($i < $num-1) + { + print 'id.'">'; + print img_down(); + print ''; + } + print ''; + } + } + else + { + print ' '; + } + + print ''; + } + + // Ligne en mode update + if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["lineid"] == $line->id) + { + print '
id.'" method="POST">'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; // ancre pour retourner sur la ligne + if ($line->fk_product > 0) + { + print ''; + print ''; + if ($line->fk_product_type==1) print img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + print ' '.$line->ref.''; + print ' - '.nl2br($line->product_label); + print '
'; + } + if ($_GET["action"] == 'editline') + { + // editeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$line->description,164,'dolibarr_details'); + $doleditor->Create(); + } + else + { + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + print ''; + } + } + print ''; + if ($conf->global->PRODUIT_USE_MARKUP) + { + print ''.vatrate($line->marge_tx).'%'; + } + print ''; + print $html->select_tva('tva_tx',$line->tva_tx,$mysoc,$societe,'',$line->info_bits); + print ''; + print ''; + print ''; + if (($line->info_bits & 2) != 2) + { + print ''; + } + else print ' '; + print ''; + print ''; + if (($line->info_bits & 2) != 2) + { + print '%'; + } + else print ' '; + print ''; + print ''; + print '
'; + print '' . "\n"; + + print "
\n"; + } +} + ?> \ No newline at end of file