Works on capability to hook a thirdparty module.

This commit is contained in:
Regis Houssin 2010-08-09 22:39:20 +00:00
parent 90538c3b69
commit 482b76e5db
5 changed files with 494 additions and 345 deletions

View File

@ -1396,13 +1396,13 @@ if ($id > 0 || ! empty($ref))
if (! empty($module->lines))
{
print_title_list();
$propal->print_title_list();
$module->printObjectList($propal, $lines, $sublines);
}
else if (! empty($lines) )
{
print_title_list();
print_lines_list($propal, $lines);
$propal->print_title_list();
$propal->printLinesList($lines);
}
}
}
@ -1412,8 +1412,8 @@ if ($id > 0 || ! empty($ref))
if (! empty($lines) )
{
print_title_list();
print_lines_list($propal, $lines);
$propal->print_title_list();
$propal->printLinesList($lines);
}
}

View File

@ -2388,6 +2388,72 @@ class Commande extends CommonObject
return -1;
}
}
/**
* \brief Return an array of order lines
* \param option 0=No filter on rang, 1=filter on rang <> 0, 2=filter on rang=0
*/
function getLinesArray($option=0)
{
$lines = array();
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,l.rang,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
$sql.= ' l.date_start,';
$sql.= ' l.date_end,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
$sql.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
$sql.= ' WHERE l.fk_commande = '.$this->id;
if ($option == 1) $sql.= ' AND l.rang <> 0';
if ($option == 2) $sql.= ' AND l.rang = 0';
$sql.= ' ORDER BY l.rang ASC, l.rowid';
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$lines[$i]->id = $obj->rowid;
$lines[$i]->description = $obj->description;
$lines[$i]->fk_product = $obj->fk_product;
$lines[$i]->ref = $obj->ref;
$lines[$i]->product_label = $obj->product_label;
$lines[$i]->product_desc = $obj->product_desc;
$lines[$i]->fk_product_type = $obj->fk_product_type;
$lines[$i]->product_type = $obj->product_type;
$lines[$i]->qty = $obj->qty;
$lines[$i]->subprice = $obj->subprice;
$lines[$i]->fk_remise_except = $obj->fk_remise_except;
$lines[$i]->remise_percent = $obj->remise_percent;
$lines[$i]->tva_tx = $obj->tva_tx;
$lines[$i]->info_bits = $obj->info_bits;
$lines[$i]->total_ht = $obj->total_ht;
$lines[$i]->total_tva = $obj->total_tva;
$lines[$i]->total_ttc = $obj->total_ttc;
$lines[$i]->special_code = $obj->special_code;
$lines[$i]->rang = $obj->rang;
$lines[$i]->date_start = $this->db->jdate($obj->date_start);
$lines[$i]->date_end = $this->db->jdate($obj->date_end);
$i++;
}
$this->db->free($resql);
}
else
{
dol_print_error($this->db);
}
return $lines;
}
}

View File

@ -60,11 +60,28 @@ $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$mesg=isset($_GET['mesg'])?$_GET['mesg']:'';
// Instantiate hooks of thirdparty module
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
{
$hooks = new Commande($db);
$hooks->callHooks('objectcard');
}
/******************************************************************************/
/* Actions */
/******************************************************************************/
// Hook of thirdparty module
if (! empty($hooks->objModules))
{
foreach($hooks->objModules as $module)
{
$module->getObjectActions($hooks);
$mesg = $module->error;
}
}
// Action clone object
if ($_REQUEST["action"] == 'confirm_clone' && $_REQUEST['confirm'] == 'yes')
{
@ -380,7 +397,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer)
$ret=$commande->fetch_thirdparty();
// Clean parameters
$suffixe = $_POST['idprod'] ? '_prod' : '';
$suffixe = $_POST['idprod'] ? '_predef' : '';
$date_start=dol_mktime(0, 0, 0, $_POST['date_start'.$suffixe.'month'], $_POST['date_start'.$suffixe.'day'], $_POST['date_start'.$suffixe.'year']);
$date_end=dol_mktime(0, 0, 0, $_POST['date_end'.$suffixe.'month'], $_POST['date_end'.$suffixe.'day'], $_POST['date_end'.$suffixe.'year']);
$price_base_type = 'HT';
@ -1657,6 +1674,44 @@ else
/*
* Lines
*/
print '<table class="noborder" width="100%">';
// Hook of thirdparty module
if (! empty($hooks->objModules))
{
foreach($hooks->objModules as $module)
{
$lines = $commande->getLinesArray(1);
$module->getObjectList($commande);
$sublines = $commande->getLinesArray(2);
if (! empty($module->lines))
{
$commande->print_title_list();
$module->printObjectList($commande, $lines, $sublines,1);
}
else if (! empty($lines) )
{
$commande->print_title_list();
$commande->printLinesList($lines,1);
}
}
}
else
{
$lines = $commande->getLinesArray(0);
if (! empty($lines) )
{
$commande->print_title_list();
$commande->printLinesList($lines,1);
}
}
/*
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
@ -1931,21 +1986,35 @@ else
{
dol_print_error($db);
}
*/
/*
* Form to add new line
*/
if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] <> 'editline')
if ($commande->statut == 0 && $user->rights->commande->creer)
{
$var=true;
$commande->showAddFreeProductForm(1);
// Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled)
if (! preg_match('/editline|edit_/',$_GET["action"]))
{
$var=!$var;
$commande->showAddPredefinedProductForm(1);
$var=true;
$commande->showAddFreeProductForm(1);
// Add predefined products/services
if ($conf->product->enabled || $conf->service->enabled)
{
$var=!$var;
$commande->showAddPredefinedProductForm(1);
}
// Hook of thirdparty module
if (! empty($hooks->objModules))
{
foreach($hooks->objModules as $module)
{
$var=!$var;
$module->formAddObject($commande);
}
}
}
}
print '</table>';

View File

@ -1222,6 +1222,350 @@ class CommonObject
return $num;
}
}
/**
* Return HTML table with title list
*/
function print_title_list()
{
global $conf,$langs;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Description').'</td>';
if ($conf->global->PRODUIT_USE_MARKUP) print '<td align="right" width="80">'.$langs->trans('Markup').'</td>';
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>';
print '<td width="48" colspan="3">&nbsp;</td>';
print "</tr>\n";
}
/**
* Return HTML with object lines list
* @param lines Object lines
*/
function printLinesList($lines,$dateSelector=0)
{
$num = count($lines);
$var = true;
$i = 0;
foreach ($lines as $line)
{
$var=!$var;
$this->printLine($line,$var,$num,$i,$dateSelector);
$i++;
}
}
/**
* Return HTML with selected object line
* @param line Selected object line
*/
function printLine($line,$var=true,$num=0,$i=0,$dateSelector=0)
{
global $conf,$langs,$user;
global $html,$bc;
$element = $this->element;
// TODO uniformiser
if ($element == 'propal') $element = 'propale';
// 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 '<tr '.$bc[$var].'>';
// Produit
if ($line->fk_product > 0)
{
$product_static = new Product($db);
print '<td>';
print '<a name="'.$line->id.'"></a>'; // 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)?'<br>'.dol_htmlentitiesbr($line->description):'';
}
print '</td>';
}
else
{
print '<td>';
print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne
if (($line->info_bits & 2) == 2)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid.'">';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '</a>';
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 "</td>\n";
}
// TODO a déplacer dans classe module marge
/*
if ($conf->global->PRODUIT_USE_MARKUP && $conf->use_javascript_ajax)
{
$formMarkup = '<form id="formMarkup" action="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'" method="post">'."\n";
$formMarkup.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
$formMarkup.= '<table class="border" width="100%">'."\n";
if ($objp->fk_product > 0)
{
$formMarkup.= '<tr><td align="left" colspan="2">&nbsp;</td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('SupplierPrice').'</td>'."\n";
$formMarkup.= '<td align="left">'.$html->select_product_fourn_price($line->fk_product,'productfournpriceid').'</td></tr>'."\n";
}
$formMarkup.= '<tr><td align="left" colspan="2">&nbsp;</td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('PurchasePrice').' '.$langs->trans('HT').'</td>'."\n";
$formMarkup.= '<td align="left"><input size="10" type="text" class="flat" name="purchaseprice_ht" value=""></td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('MarkupRate').'</td>'."\n";
$formMarkup.= '<td><input size="10" type="text" class="flat" id="markuprate'.$i.'" name="markuprate'.$i.'" value=""></td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('SellingPrice').' '.$langs->trans('HT').'</td>'."\n";
//$formMarkup.= '<td><div id="sellingprice_ht'.$i.'"><input size="10" type="text" class="flat" id="sellingdata_ht'.$i.'" name="sellingdata_ht'.$i.'" value=""></div></td></tr>'."\n";
$formMarkup.= '<td nowrap="nowrap"><div id="sellingprice_ht'.$i.'"><div></td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('CashFlow').' '.$langs->trans('HT').'</td>'."\n";
$formMarkup.= '<td nowrap="nowrap"><div id="cashflow'.$i.'"></div></td></tr>'."\n";
$formMarkup.= '<tr><td align="center" colspan="2">'."\n";
$formMarkup.= '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">'."\n";
//$formMarkup.= ' &nbsp; <input onClick="Dialog.closeInfo()" type="button" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'."\n";
$formMarkup.= '</td></tr></table></form>'."\n";
$formMarkup.= ajax_updaterWithID("rate".$i,"markup","sellingprice_ht".$i,DOL_URL_ROOT."/product/ajaxproducts.php","&count=".$i,"working")."\n";
print '<td align="right">'."\n";
print '<div id="calc_markup'.$i.'" style="display:none">'."\n";
print $formMarkup."\n";
print '</div>'."\n";
print '<table class="nobordernopadding" width="100%"><tr class="nocellnopadd">';
print '<td class="nobordernopadding" nowrap="nowrap" align="left">';
if (($objp->info_bits & 2) == 2)
{
// Ligne remise predefinie, on ne permet pas modif
}
else
{
$picto = '<a href="#" onClick="dialogWindow($(\'calc_markup'.$i.'\').innerHTML,\''.$langs->trans('ToCalculateMarkup').'\')">';
$picto.= img_picto($langs->trans("Calculate"),'calc.png');
$picto.= '</a>';
print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i);
}
print '</td>';
print '<td class="nobordernopadding" nowrap="nowrap" align="right">'.vatrate($line->marge_tx).'% </td>';
print '</tr></table>';
print '</td>';
}
*/
// VAT Rate
print '<td align="right" nowrap="nowrap">'.vatrate($line->tva_tx,'%',$line->info_bits).'</td>';
// U.P HT
print '<td align="right" nowrap="nowrap">'.price($line->subprice)."</td>\n";
// Qty
print '<td align="right" nowrap="nowrap">';
if ((($line->info_bits & 2) != 2) && $line->special_code != 3)
{
print $line->qty;
}
else print '&nbsp;';
print '</td>';
// Remise percent (negative or positive)
if (!empty($line->remise_percent) && $line->special_code != 3)
{
print '<td align="right">'.dol_print_reduction($line->remise_percent,$langs)."</td>\n";
}
else
{
print '<td>&nbsp;</td>';
}
// Montant total HT
if ($line->special_code == 3)
{
// Si ligne en option
print '<td align="right" nowrap="nowrap">'.$langs->trans('Option').'</td>';
}
else
{
print '<td align="right" nowrap="nowrap">'.price($line->total_ht)."</td>\n";
}
// Icone d'edition et suppression
if ($this->statut == 0 && $user->rights->$element->creer)
{
print '<td align="center">';
if (($line->info_bits & 2) == 2)
{
// Ligne remise predefinie, on permet pas modif
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#'.$line->id.'">';
print img_edit();
print '</a>';
}
print '</td>';
print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=ask_deleteline&amp;lineid='.$line->id.'">';
print img_delete();
print '</a></td>';
if ($num > 1)
{
print '<td align="center">';
if ($i > 0)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id.'">';
print img_up();
print '</a>';
}
if ($i < $num-1)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id.'">';
print img_down();
print '</a>';
}
print '</td>';
}
}
else
{
print '<td colspan="3">&nbsp;</td>';
}
print '</tr>';
}
// Ligne en mode update
if ($this->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["lineid"] == $line->id)
{
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="id" value="'.$this->id.'">';
print '<input type="hidden" name="lineid" value="'.$_GET["lineid"].'">';
print '<tr '.$bc[$var].'>';
print '<td>';
print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
if ($line->fk_product > 0)
{
print '<input type="hidden" name="productid" value="'.$line->fk_product.'">';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product.'">';
if ($line->fk_product_type==1) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
print ' '.$line->ref.'</a>';
print ' - '.nl2br($line->product_label);
print '<br>';
}
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 '<textarea name="desc" cols="70" class="flat" rows="'.$nbrows.'">'.dol_htmlentitiesbr_decode($line->description).'</textarea>';
}
}
print '</td>';
// TODO a déplacer dans classe module marge
//if ($conf->global->PRODUIT_USE_MARKUP) print '<td align="right">'.vatrate($line->marge_tx).'%</td>';
print '<td align="right">';
print $html->select_tva('tva_tx',$line->tva_tx,$mysoc,$societe,'',$line->info_bits);
print '</td>';
print '<td align="right"><input size="6" type="text" class="flat" name="subprice" value="'.price($line->subprice,0,'',0).'"></td>';
print '<td align="right">';
if (($line->info_bits & 2) != 2)
{
print '<input size="2" type="text" class="flat" name="qty" value="'.$line->qty.'">';
}
else print '&nbsp;';
print '</td>';
print '<td align="right" nowrap>';
if (($line->info_bits & 2) != 2)
{
print '<input size="1" type="text" class="flat" name="remise_percent" value="'.$line->remise_percent.'">%';
}
else print '&nbsp;';
print '</td>';
print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
print '</tr>' . "\n";
// Start and end dates selector
if ($conf->service->enabled && $dateSelector)
{
print '<tr '.$bc[$var].'>';
print '<td colspan="9">'.$langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
print $html->select_date($line->date_start,'date_start',$usehm,$usehm,$line->date_start?0:1,"updateligne");
print ' '.$langs->trans('to').' ';
print $html->select_date($line->date_end,'date_end',$usehm,$usehm,$line->date_end?0:1,"updateligne");
print '</td>';
print '</tr>';
}
print "</form>\n";
}
}
}

View File

@ -111,335 +111,5 @@ function propal_prepare_head($propal)
return $head;
}
/**
* \brief Return HTML table with title list
* \param propal Object propal
* \param lines Array of propal lines
*/
function print_title_list()
{
global $conf,$langs;
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Description').'</td>';
if ($conf->global->PRODUIT_USE_MARKUP) print '<td align="right" width="80">'.$langs->trans('Markup').'</td>';
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>';
print '<td width="48" colspan="3">&nbsp;</td>';
print "</tr>\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;
foreach ($lines as $line)
{
$var=!$var;
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 '<tr '.$bc[$var].'>';
// Produit
if ($line->fk_product > 0)
{
$product_static = new Product($db);
print '<td>';
print '<a name="'.$line->id.'"></a>'; // 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)?'<br>'.dol_htmlentitiesbr($line->description):'';
}
print '</td>';
}
else
{
print '<td>';
print '<a name="'.$line->rowid.'"></a>'; // ancre pour retourner sur la ligne
if (($line->info_bits & 2) == 2)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socid.'">';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '</a>';
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 "</td>\n";
}
if ($conf->global->PRODUIT_USE_MARKUP && $conf->use_javascript_ajax)
{
// TODO a déplacer dans classe module marge
$formMarkup = '<form id="formMarkup" action="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'" method="post">'."\n";
$formMarkup.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
$formMarkup.= '<table class="border" width="100%">'."\n";
if ($objp->fk_product > 0)
{
$formMarkup.= '<tr><td align="left" colspan="2">&nbsp;</td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('SupplierPrice').'</td>'."\n";
$formMarkup.= '<td align="left">'.$html->select_product_fourn_price($line->fk_product,'productfournpriceid').'</td></tr>'."\n";
}
$formMarkup.= '<tr><td align="left" colspan="2">&nbsp;</td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('PurchasePrice').' '.$langs->trans('HT').'</td>'."\n";
$formMarkup.= '<td align="left"><input size="10" type="text" class="flat" name="purchaseprice_ht" value=""></td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('MarkupRate').'</td>'."\n";
$formMarkup.= '<td><input size="10" type="text" class="flat" id="markuprate'.$i.'" name="markuprate'.$i.'" value=""></td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('SellingPrice').' '.$langs->trans('HT').'</td>'."\n";
//$formMarkup.= '<td><div id="sellingprice_ht'.$i.'"><input size="10" type="text" class="flat" id="sellingdata_ht'.$i.'" name="sellingdata_ht'.$i.'" value=""></div></td></tr>'."\n";
$formMarkup.= '<td nowrap="nowrap"><div id="sellingprice_ht'.$i.'"><div></td></tr>'."\n";
$formMarkup.= '<tr><td align="left" width="25%" height="19">&nbsp;'.$langs->trans('CashFlow').' '.$langs->trans('HT').'</td>'."\n";
$formMarkup.= '<td nowrap="nowrap"><div id="cashflow'.$i.'"></div></td></tr>'."\n";
$formMarkup.= '<tr><td align="center" colspan="2">'."\n";
$formMarkup.= '<input type="submit" class="button" name="validate" value="'.$langs->trans('Validate').'">'."\n";
//$formMarkup.= ' &nbsp; <input onClick="Dialog.closeInfo()" type="button" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'."\n";
$formMarkup.= '</td></tr></table></form>'."\n";
$formMarkup.= ajax_updaterWithID("rate".$i,"markup","sellingprice_ht".$i,DOL_URL_ROOT."/product/ajaxproducts.php","&count=".$i,"working")."\n";
print '<td align="right">'."\n";
print '<div id="calc_markup'.$i.'" style="display:none">'."\n";
print $formMarkup."\n";
print '</div>'."\n";
print '<table class="nobordernopadding" width="100%"><tr class="nocellnopadd">';
print '<td class="nobordernopadding" nowrap="nowrap" align="left">';
if (($objp->info_bits & 2) == 2)
{
// Ligne remise predefinie, on ne permet pas modif
}
else
{
$picto = '<a href="#" onClick="dialogWindow($(\'calc_markup'.$i.'\').innerHTML,\''.$langs->trans('ToCalculateMarkup').'\')">';
$picto.= img_picto($langs->trans("Calculate"),'calc.png');
$picto.= '</a>';
print $html->textwithtooltip($picto,$langs->trans("ToCalculateMarkup"),3,'','',$i);
}
print '</td>';
print '<td class="nobordernopadding" nowrap="nowrap" align="right">'.vatrate($line->marge_tx).'% </td>';
print '</tr></table>';
print '</td>';
}
// VAT Rate
print '<td align="right" nowrap="nowrap">'.vatrate($line->tva_tx,'%',$line->info_bits).'</td>';
// U.P HT
print '<td align="right" nowrap="nowrap">'.price($line->subprice)."</td>\n";
// Qty
print '<td align="right" nowrap="nowrap">';
if ((($line->info_bits & 2) != 2) && $line->special_code != 3)
{
print $line->qty;
}
else print '&nbsp;';
print '</td>';
// Remise percent (negative or positive)
if (!empty($line->remise_percent) && $line->special_code != 3)
{
print '<td align="right">'.dol_print_reduction($line->remise_percent,$langs)."</td>\n";
}
else
{
print '<td>&nbsp;</td>';
}
// Montant total HT
if ($line->special_code == 3)
{
// Si ligne en option
print '<td align="right" nowrap="nowrap">'.$langs->trans('Option').'</td>';
}
else
{
print '<td align="right" nowrap="nowrap">'.price($line->total_ht)."</td>\n";
}
// Icone d'edition et suppression
if ($propal->statut == 0 && $user->rights->propale->creer)
{
print '<td align="center">';
if (($line->info_bits & 2) == 2)
{
// Ligne remise predefinie, on permet pas modif
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&amp;action=editline&amp;lineid='.$line->id.'#'.$line->id.'">';
print img_edit();
print '</a>';
}
print '</td>';
print '<td align="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&amp;action=ask_deleteline&amp;lineid='.$line->id.'">';
print img_delete();
print '</a></td>';
if ($num > 1)
{
print '<td align="center">';
if ($i > 0)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&amp;action=up&amp;rowid='.$line->id.'">';
print img_up();
print '</a>';
}
if ($i < $num-1)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&amp;action=down&amp;rowid='.$line->id.'">';
print img_down();
print '</a>';
}
print '</td>';
}
}
else
{
print '<td colspan="3">&nbsp;</td>';
}
print '</tr>';
}
// Ligne en mode update
if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["lineid"] == $line->id)
{
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'#'.$line->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="id" value="'.$propal->id.'">';
print '<input type="hidden" name="lineid" value="'.$_GET["lineid"].'">';
print '<tr '.$bc[$var].'>';
print '<td>';
print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne
if ($line->fk_product > 0)
{
print '<input type="hidden" name="productid" value="'.$line->fk_product.'">';
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product.'">';
if ($line->fk_product_type==1) print img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
print ' '.$line->ref.'</a>';
print ' - '.nl2br($line->product_label);
print '<br>';
}
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 '<textarea name="desc" cols="70" class="flat" rows="'.$nbrows.'">'.dol_htmlentitiesbr_decode($line->description).'</textarea>';
}
}
print '</td>';
if ($conf->global->PRODUIT_USE_MARKUP)
{
print '<td align="right">'.vatrate($line->marge_tx).'%</td>';
}
print '<td align="right">';
print $html->select_tva('tva_tx',$line->tva_tx,$mysoc,$societe,'',$line->info_bits);
print '</td>';
print '<td align="right"><input size="6" type="text" class="flat" name="subprice" value="'.price($line->subprice,0,'',0).'"></td>';
print '<td align="right">';
if (($line->info_bits & 2) != 2)
{
print '<input size="2" type="text" class="flat" name="qty" value="'.$line->qty.'">';
}
else print '&nbsp;';
print '</td>';
print '<td align="right" nowrap>';
if (($line->info_bits & 2) != 2)
{
print '<input size="1" type="text" class="flat" name="remise_percent" value="'.$line->remise_percent.'">%';
}
else print '&nbsp;';
print '</td>';
print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
print '</tr>' . "\n";
print "</form>\n";
}
}
?>