New: [ task #498 ] part3

This commit is contained in:
Regis Houssin
2012-08-23 13:45:51 +02:00
parent f4d75e87d3
commit 995c7f13d3
16 changed files with 444 additions and 737 deletions

View File

@@ -1569,7 +1569,7 @@ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
* Lines * Lines
*/ */
if ($conf->use_javascript_ajax && $object->statut == 0) if (! empty($conf->use_javascript_ajax) && $object->statut == 0)
{ {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
@@ -1578,7 +1578,8 @@ print '<table id="tablelines" class="noborder" width="100%">';
// Show object lines // Show object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); if (! empty($object->lines))
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager);
// Form to add new line // Form to add new line
if ($object->statut == 0 && $user->rights->propale->creer) if ($object->statut == 0 && $user->rights->propale->creer)
@@ -1588,10 +1589,10 @@ if ($object->statut == 0 && $user->rights->propale->creer)
$var=true; $var=true;
// Add free or predefined products/services // Add free or predefined products/services
$object->formAddFreeProduct(0,$mysoc,$soc,$hookmanager); $object->formAddObjectLine(0,$mysoc,$soc,$hookmanager);
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
} }
} }

View File

@@ -2764,9 +2764,7 @@ class PropaleLigne
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET";
$sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " description='".$this->db->escape($this->desc)."'";
if (! empty($this->label)) { $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
$sql.= " , label='".$this->db->escape($this->label)."'";
}
$sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , tva_tx='".price2num($this->tva_tx)."'";
$sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax1_tx=".price2num($this->localtax1_tx);
$sql.= " , localtax2_tx=".price2num($this->localtax2_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx);

View File

@@ -3126,9 +3126,7 @@ class OrderLine
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
$sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " description='".$this->db->escape($this->desc)."'";
if (empty($this->label)) { $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
$sql.= " , label='".$this->db->escape($this->label)."'";
}
$sql.= " , tva_tx=".price2num($this->tva_tx); $sql.= " , tva_tx=".price2num($this->tva_tx);
$sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax1_tx=".price2num($this->localtax1_tx);
$sql.= " , localtax2_tx=".price2num($this->localtax2_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx);

View File

@@ -552,9 +552,8 @@ else if ($action == 'addline' && $user->rights->commande->creer)
if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod))) if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod)))
{ {
// Clean parameters // Clean parameters
$suffixe = (! empty($idprod) ? '_predef' : ''); $date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); $date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year'));
$price_base_type = 'HT'; $price_base_type = 'HT';
// Ecrase $pu par celui du produit // Ecrase $pu par celui du produit
@@ -754,10 +753,10 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
// Clean parameters // Clean parameters
$date_start=''; $date_start='';
$date_end=''; $date_end='';
$date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); $date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year')); $date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description=dol_htmlcleanlastbr(GETPOST('desc')); $description=dol_htmlcleanlastbr(GETPOST('product_desc'));
$up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); $pu_ht=GETPOST('price_ht');
// Define info_bits // Define info_bits
$info_bits=0; $info_bits=0;
@@ -769,37 +768,37 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
$localtax1_rate=get_localtax($vat_rate,1,$object->client); $localtax1_rate=get_localtax($vat_rate,1,$object->client);
$localtax2_rate=get_localtax($vat_rate,2,$object->client); $localtax2_rate=get_localtax($vat_rate,2,$object->client);
// Add buying price
// ajout prix d'achat $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):'');
$fk_fournprice = GETPOST('fournprice'); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):'');
if (GETPOST('buying_price'))
$pa_ht = GETPOST('buying_price');
else
$pa_ht = null;
// Check minimum price // Check minimum price
if (GETPOST('productid')) if (GETPOST('productid', 'int'))
{ {
$productid = GETPOST('productid'); $productid = GETPOST('productid', 'int');
$product = new Product($db); $product = new Product($db);
$product->fetch($productid); $product->fetch($productid);
$type=$product->type; $type=$product->type;
$price_min = $product->price_min; $price_min = $product->price_min;
if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level]; if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level)
$price_min = $product->multiprices_min[$object->client->price_level];
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):'');
if ($price_min && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) if ($price_min && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{ {
$mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>' ; setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).getCurrencySymbol($conf->currency), 'errors');
$error++; $error++;
} }
} }
else else
{ {
$type=GETPOST('type'); $type = GETPOST('type');
$label = (GETPOST('product_label') ? GETPOST('product_label'):'');
// Check parameters // Check parameters
if (GETPOST('type') < 0) { if (GETPOST('type') < 0) {
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>'; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")));
$error++; $error++;
} }
} }
@@ -809,7 +808,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
$result = $object->updateline( $result = $object->updateline(
GETPOST('lineid'), GETPOST('lineid'),
$description, $description,
$up_ht, $pu_ht,
GETPOST('qty'), GETPOST('qty'),
GETPOST('remise_percent'), GETPOST('remise_percent'),
$vat_rate, $vat_rate,
@@ -822,38 +821,46 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
$type, $type,
GETPOST('fk_parent_line'), GETPOST('fk_parent_line'),
0, 0,
$fk_fournprice, $fournprice,
$pa_ht $buyingprice,
$label
); );
if ($result >= 0) if ($result >= 0)
{ {
// Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
$outputlangs = $langs;
$newlang='';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
if (! empty($newlang))
{ {
$outputlangs = new Translate("",$conf); // Define output language
$outputlangs->setDefaultLang($newlang); $outputlangs = $langs;
} $newlang='';
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
{ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
$ret=$object->fetch($object->id); // Reload to get new records if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$ret=$object->fetch($object->id); // Reload to get new records
commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager);
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['np_price']);
unset($_POST['dp_desc']);
unset($_POST['np_tva_tx']);
unset($_POST['np_buying_price']);
} }
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['productid']);
unset($_POST['remise_percent']);
unset($_POST['price_ht']);
unset($_POST['price_ttc']);
unset($_POST['tva_tx']);
unset($_POST['product_ref']);
unset($_POST['product_label']);
unset($_POST['product_desc']);
unset($_POST['fournprice']);
unset($_POST['buying_price']);
} }
else else
{ {
dol_print_error($db,$object->error); setEventMessage($object->error, 'errors');
exit;
} }
} }
} }
@@ -2114,7 +2121,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
$numlines = count($object->lines); $numlines = count($object->lines);
if ($conf->use_javascript_ajax && $object->statut == 0) if (! empty($conf->use_javascript_ajax) && $object->statut == 0)
{ {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
@@ -2122,7 +2129,8 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
print '<table id="tablelines" class="noborder" width="100%">'; print '<table id="tablelines" class="noborder" width="100%">';
// Show object lines // Show object lines
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); if (! empty($object->lines))
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager);
/* /*
* Form to add new line * Form to add new line
@@ -2133,10 +2141,10 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
{ {
$var=true; $var=true;
$object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager);
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
} }
} }
print '</table>'; print '</table>';

View File

@@ -982,9 +982,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$ret=$object->fetch_thirdparty(); $ret=$object->fetch_thirdparty();
// Clean parameters // Clean parameters
$suffixe = (! empty($idprod) ? '_predef' : ''); $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_start=dol_mktime(GETPOST('date_start'.$suffixe.'hour'), GETPOST('date_start'.$suffixe.'min'), GETPOST('date_start'.$suffixe.'sec'), GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$date_end=dol_mktime(GETPOST('date_end'.$suffixe.'hour'), GETPOST('date_end'.$suffixe.'min'), GETPOST('date_end'.$suffixe.'sec'), GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year'));
$price_base_type = 'HT'; $price_base_type = 'HT';
// Ecrase $pu par celui du produit // Ecrase $pu par celui du produit
@@ -1112,7 +1111,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
$info_bits=0; $info_bits=0;
if ($tva_npr) $info_bits |= 0x01; if ($tva_npr) $info_bits |= 0x01;
if (! empty($price_min) && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{ {
$mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency)); $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency));
setEventMessage($mesg, 'errors'); setEventMessage($mesg, 'errors');
@@ -1197,8 +1196,8 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa
// Clean parameters // Clean parameters
$date_start=''; $date_start='';
$date_end=''; $date_end='';
$date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']); $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description=dol_htmlcleanlastbr($_POST['desc']); $description=dol_htmlcleanlastbr($_POST['desc']);
$up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); $up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice');
@@ -2970,7 +2969,7 @@ else if ($id > 0 || ! empty($ref))
*/ */
$result = $object->getLinesArray(); $result = $object->getLinesArray();
if ($conf->use_javascript_ajax && $object->statut == 0) if (! empty($conf->use_javascript_ajax) && $object->statut == 0)
{ {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
@@ -2978,7 +2977,8 @@ else if ($id > 0 || ! empty($ref))
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
// Show object lines // Show object lines
if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); if (! empty($object->lines))
$ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager);
/* /*
* Form to add new line * Form to add new line
@@ -2987,10 +2987,10 @@ else if ($id > 0 || ! empty($ref))
{ {
$var=true; $var=true;
$object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager);
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
} }
print "</table>\n"; print "</table>\n";

View File

@@ -3420,9 +3420,7 @@ class FactureLigne
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET";
$sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " description='".$this->db->escape($this->desc)."'";
if (! empty($this->label)) { $sql.= ",label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
$sql.= " , label='".$this->db->escape($this->label)."'";
}
$sql.= ",subprice=".price2num($this->subprice).""; $sql.= ",subprice=".price2num($this->subprice)."";
$sql.= ",remise_percent=".price2num($this->remise_percent).""; $sql.= ",remise_percent=".price2num($this->remise_percent)."";
if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except; if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;

View File

@@ -43,22 +43,23 @@ top_httphead();
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; //print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Load original field value // Load original field value
if (! empty($action) && (isset($pu_ht) || isset($pu_ttc)) && isset($tva_tx)) if (! empty($action) && isset($tva_tx))
{ {
$return=array(); $return=array();
$price='';
if ($action == 'get_ttc') { if ($action == 'get_ttc' && isset($pu_ht) && $pu_ht != '') {
$price = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); $price = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU');
} }
else if ($action == 'get_ht') { else if ($action == 'get_ht' && isset($pu_ttc) && $pu_ttc != '') {
$price = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); $price = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU');
} }
$return['price'] = price($price); $return['price'] = (isset($price) && $price != '' ? price($price) : '');
echo json_encode($return); echo json_encode($return);
} }

View File

@@ -2446,43 +2446,17 @@ abstract class CommonObject
/** /**
* Show add predefined products/services form * Show add free and predefined products/services form
* TODO Edit templates to use global variables and include them directly in controller call * TODO Edit templates to use global variables and include them directly in controller call
* 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 as we keep a method available on overloaded objects.
* *
* @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance
* @return void
*/
function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false)
{
global $conf,$langs,$object;
global $form,$bcnd,$var;
// 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'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/predefinedproductline_create.tpl.php');
if ($res) break;
}
}
/**
* Show add free products/services form
* TODO Edit templates to use global variables and include them directly in controller call
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
*
* @param int $dateSelector 1=Show also date range input fields * @param int $dateSelector 1=Show also date range input fields
* @param Societe $seller Object thirdparty who sell * @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy * @param Societe $buyer Object thirdparty who buy
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return void * @return void
*/ */
function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) function formAddObjectLine($dateSelector,$seller,$buyer,$hookmanager=false)
{ {
global $conf,$user,$langs,$object; global $conf,$user,$langs,$object;
global $form,$bcnd,$var; global $form,$bcnd,$var;
@@ -2492,11 +2466,11 @@ abstract class CommonObject
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir) foreach($dirtpls as $reldir)
{ {
// for view errors $tpl = dol_buildpath($reldir.'/objectline_add.tpl.php');
if ($conf->file->strict_mode) { if (empty($conf->file->strict_mode)) {
$res=include dol_buildpath($reldir.'/freeproductline_create.tpl.php'); $res=@include $tpl;
} else { } else {
$res=@include dol_buildpath($reldir.'/freeproductline_create.tpl.php'); $res=include $tpl; // for debug
} }
if ($res) break; if ($res) break;
} }
@@ -2580,8 +2554,6 @@ abstract class CommonObject
/** /**
* Return HTML content of a detail line * Return HTML content of a detail line
* TODO Move this into an output class file (htmlline.class.php) * TODO Move this into an output 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.
* *
* @param string $action GET/POST action * @param string $action GET/POST action
* @param array $line Selected object line to output * @param array $line Selected object line to output
@@ -2601,13 +2573,23 @@ abstract class CommonObject
global $form,$bc,$bcdd; global $form,$bc,$bcdd;
$element=$this->element; $element=$this->element;
$text='';
// Show product and description // Show product and description
$type=$line->product_type?$line->product_type:$line->fk_product_type; $type=(! empty($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 // Try to enhance type detection using date_start and date_end for free lines where type was not saved.
// was not saved. if (! empty($line->date_start)) $type=1; // deprecated
if (! empty($line->date_start)) $type=1; if (! empty($line->date_end)) $type=1; // deprecated
if (! empty($line->date_end)) $type=1;
if ($line->fk_product > 0)
{
$product_static = new Product($this->db);
$product_static->type=$line->fk_product_type;
$product_static->id=$line->fk_product;
$product_static->ref=$line->ref;
$text=$product_static->getNomUrl(1);
}
// Ligne en mode visu // Ligne en mode visu
if ($action != 'editline' || $selected != $line->id) if ($action != 'editline' || $selected != $line->id)
@@ -2615,13 +2597,11 @@ abstract class CommonObject
// Produit // Produit
if ($line->fk_product > 0) if ($line->fk_product > 0)
{ {
$product_static = new Product($this->db);
// Define output language // Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{ {
$this->fetch_thirdparty(); $this->fetch_thirdparty();
$prod = new Product($this->db, $line->fk_product); $prod = new Product($this->db);
$outputlangs = $langs; $outputlangs = $langs;
$newlang=''; $newlang='';
@@ -2640,59 +2620,46 @@ abstract class CommonObject
$label = $line->product_label; $label = $line->product_label;
} }
$product_static->type=$line->fk_product_type;
$product_static->id=$line->fk_product;
$product_static->ref=$line->ref;
$text=$product_static->getNomUrl(1);
$text.= ' - '.(! empty($line->label)?$line->label:$label); $text.= ' - '.(! empty($line->label)?$line->label:$label);
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description));
// 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'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/predefinedproductline_view.tpl.php');
if ($res) break;
}
} }
else
// 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'));
foreach($dirtpls as $reldir)
{ {
// Output template part (modules that overwrite templates must declare this into descriptor) $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php');
// Use global variables + $dateSelector + $seller and $buyer if (empty($conf->file->strict_mode)) {
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); $res=@include $tpl;
foreach($dirtpls as $reldir) } else {
{ $res=include $tpl; // for debug
$res=@include dol_buildpath($reldir.'/freeproductline_view.tpl.php'); }
if ($res) break; if ($res) break;
}
} }
} }
// Ligne en mode update // Ligne en mode update
if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) if ($this->statut == 0 && $action == 'editline' && $selected == $line->id)
{ {
if ($line->fk_product > 0) $label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : ''));
if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"';
else $placeholder=' title="'.$langs->trans("Label").'"';
$pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
// 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'));
foreach($dirtpls as $reldir)
{ {
// Output template part (modules that overwrite templates must declare this into descriptor) $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php');
// Use global variables + $dateSelector + $seller and $buyer if (empty($conf->file->strict_mode)) {
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); $res=@include $tpl;
foreach($dirtpls as $reldir) } else {
{ $res=include $tpl; // for debug
$res=@include dol_buildpath($reldir.'/predefinedproductline_edit.tpl.php'); }
if ($res) break; if ($res) break;
}
}
else
{
// 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'));
foreach($dirtpls as $reldir)
{
$res=@include dol_buildpath($reldir.'/freeproductline_edit.tpl.php');
if ($res) break;
}
} }
} }
} }

View File

@@ -739,7 +739,7 @@ function hideMessage(fieldId,message) {
$.widget("ui.onDelayedKeyup", { $.widget("ui.onDelayedKeyup", {
_init : function() { _init : function() {
var self = this; var self = this;
$(this.element).keyup(function() { $(this.element).bind('change keyup input', function() {
if(typeof(window['inputTimeout']) != "undefined"){ if(typeof(window['inputTimeout']) != "undefined"){
window.clearTimeout(inputTimeout); window.clearTimeout(inputTimeout);
} }

View File

@@ -1,101 +0,0 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Need to have following variables defined:
* $conf
* $langs
* $dateSelector
* $this (invoice, order, ...)
* $line defined
*/
?>
<!-- BEGIN PHP TEMPLATE freeproductline_edit.tpl.php -->
<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="updateligne">
<input type="hidden" name="id" value="<?php echo $this->id; ?>">
<input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
<input type="hidden" name="type" value="<?php echo $line->product_type; ?>">
<tr <?php echo $bc[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
<div id="<?php echo $line->id; ?>"></div>
<?php
if (is_object($hookmanager))
{
$parameters=array('line'=>$line,'fk_parent_line'=>$line->fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer);
$reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action);
}
// editeur wysiwyg
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
?>
</td>
<td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?></td>
<td align="right"><input size="6" type="text" class="flat" name="subprice" value="<?php echo price($line->subprice,0,'',0); ?>"></td>
<td align="right">
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="2" type="text" class="flat" name="qty" value="<?php echo $line->qty; ?>">
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
<td align="right" nowrap>
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>">%
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
<?php
if (! empty($conf->margin->enabled)) {
?>
<td align="right"><input type="text" size="5" name="buying_price" value="<?php echo price($line->pa_ht,0,'',0); ?>"></td>
<?php
}
?>
<td align="center" colspan="5" valign="middle"><input type="submit" class="button" name="save" value="<?php echo $langs->trans("Save"); ?>">
<br><input type="submit" class="button" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>"></td>
</tr>
<?php if ($conf->service->enabled && $dateSelector && $line->product_type == 1) { ?>
<tr <?php echo $bc[$var]; ?>>
<td colspan="9"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?>
<?php
echo $form->select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne");
echo ' '.$langs->trans('to').' ';
echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne");
?>
</td>
</tr>
<?php } ?>
</form>
<!-- END PHP TEMPLATE freeproductline_edit.tpl.php -->

View File

@@ -235,10 +235,14 @@ $(document).ready(function() {
$('#add_service_text').show(); $('#add_service_text').show();
$('#service_duration_area').show(); $('#service_duration_area').show();
} }
//$('#add_product_area').show(); //$('#add_product_area').show(); // TODO for add product card
$('#addlinebutton').removeAttr('disabled'); if (($('#price_ht').val().length > 0) || ($('#price_ttc').val().length > 0)) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
}
} else { } else {
//$('#add_product_area').hide(); //$('#add_product_area').hide(); // TODO for add product card
$('#add_product_checkbox').removeAttr('checked'); $('#add_product_checkbox').removeAttr('checked');
$('#addlinebutton').attr('disabled','disabled'); $('#addlinebutton').attr('disabled','disabled');
$('#service_duration_area').hide(); $('#service_duration_area').hide();
@@ -348,6 +352,14 @@ $(document).ready(function() {
function(data) { function(data) {
if (data && data.price.length > 0) { if (data && data.price.length > 0) {
$('#price_ttc').val(data.price); $('#price_ttc').val(data.price);
if ($('#select_type').val() >= 0) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
}
} else {
$('#price_ttc').val('');
$('#addlinebutton').attr('disabled','disabled');
} }
}, 'json'); }, 'json');
} }
@@ -362,6 +374,14 @@ $(document).ready(function() {
function(data) { function(data) {
if (data && data.price.length > 0) { if (data && data.price.length > 0) {
$('#price_ht').val(data.price); $('#price_ht').val(data.price);
if ($('#select_type').val() >= 0) {
$('#addlinebutton').removeAttr('disabled');
} else {
$('#addlinebutton').attr('disabled','disabled');
}
} else {
$('#price_ht').val('');
$('#addlinebutton').attr('disabled','disabled');
} }
}, 'json'); }, 'json');
} }

View File

@@ -0,0 +1,260 @@
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Need to have following variables defined:
* $conf
* $langs
* $dateSelector
* $this (invoice, order, ...)
* $line defined
*/
?>
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="updateligne">
<input type="hidden" name="id" value="<?php echo $this->id; ?>">
<input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
<input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>">
<input type="hidden" id="product_id" name="productid" value="<?php echo (! empty($line->fk_product)?$line->fk_product:''); ?>" />
<tr <?php echo $bc[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
<div id="<?php echo $line->id; ?>"></div>
<?php if ($line->fk_product > 0) { ?>
<?php echo $text . ' - '; ?>
<?php } else { ?>
<?php echo $form->select_type_of_lines($line->product_type, 'type', 1, 1); ?>
<?php } ?>
<input id="product_label" name="product_label" size="40" value="<?php echo $label; ?>"<?php echo $placeholder . ((! empty($line->fk_product) && empty($line->label)) ? ' disabled="disabled"' : ''); ?>>
<span id="update_label_area" class="hideobject"><input type="checkbox" id="update_label_checkbox" name="update_label" value="1" />
<?php echo $form->textwithtooltip($langs->trans('UpdateOriginalProductLabel'), $langs->trans('HelpUpdateOriginalProductLabel'),1,0,'','',3); ?>
</span>
<br>
<?php
if (is_object($hookmanager))
{
$fk_parent_line = (GETPOST('fk_parent_line') ? GETPOST('fk_parent_line') : $line->fk_parent_line);
$parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer);
$reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action);
}
// editeur wysiwyg
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('product_desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
?>
</td>
<td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?></td>
<td align="right"><input type="text" class="flat" size="6" id="price_ht" name="price_ht" value="<?php echo price($line->subprice,0,'',0); ?>"></td>
<td align="right"><input type="text" class="flat" size="6" id="price_ttc" name="price_ttc" value="<?php echo price($pu_ttc,0,'',0); ?>"></td>
<td align="right">
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="2" type="text" class="flat" name="qty" value="<?php echo $line->qty; ?>">
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
<td align="right" nowrap>
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>">%
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
<?php if (! empty($conf->margin->enabled)) { ?>
<td align="right">
<select id="fournprice" name="fournprice" class="hideobject"></select>
<input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">
</td>
<?php } ?>
<td align="center" colspan="5" valign="middle">
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
<input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
</td>
</tr>
<?php if ($conf->service->enabled && $dateSelector) { ?>
<tr id="service_duration_area" <?php echo $bc[$var]; ?>>
<td colspan="11"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?>
<?php
echo $form->select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne");
echo ' '.$langs->trans('to').' ';
echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne");
?>
</td>
</tr>
<?php } ?>
</form>
<script type="text/javascript">
$(document).ready(function() {
if ($('#product_type').val() == 0) {
$('#service_duration_area').hide();
} else if ($('#product_type').val() == 1) {
$('#service_duration_area').show();
}
if ($('#product_label').attr('disabled')) {
$('#update_label_area').show();
}
$('#update_label_checkbox').change(function() {
if ($(this).attr('checked')) {
$('#product_label').removeAttr('disabled').focus();
} else {
$('#product_label').attr('disabled','disabled');
}
});
$('#select_type').change(function() {
var type = $(this).val();
if (type >= 0) {
if (type == 0) {
$('#service_duration_area').hide();
$('#date_start').val('').trigger('change');
$('#date_end').val('').trigger('change');
} else if (type == 1) {
$('#service_duration_area').show();
}
if (($('#price_ht').val().length > 0) || ($('#price_ttc').val().length > 0)) {
$('#savelinebutton').removeAttr('disabled');
} else {
$('#savelinebutton').attr('disabled','disabled');
}
} else {
$('#savelinebutton').attr('disabled','disabled');
$('#service_duration_area').hide();
$('#date_start').val('').trigger('change');
$('#date_end').val('').trigger('change');
}
});
$('#price_ht').onDelayedKeyup({ handler: function() {
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', {
'action': 'get_ttc',
'pu_ht': $(this).val(),
'tva_tx': $('#tva_tx').val()
},
function(data) {
if (data && data.price.length > 0) {
$('#price_ttc').val(data.price);
if (($('#product_id').val().length > 0) || ($('#select_type').val() >= 0)) {
$('#savelinebutton').removeAttr('disabled');
} else {
$('#savelinebutton').attr('disabled','disabled');
}
} else {
$('#price_ttc').val('');
$('#savelinebutton').attr('disabled','disabled');
}
}, 'json');
}
});
$('#price_ttc').onDelayedKeyup({ handler: function() {
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', {
'action': 'get_ht',
'pu_ttc': $(this).val(),
'tva_tx': $('#tva_tx').val()
},
function(data) {
if (data && data.price.length > 0) {
$('#price_ht').val(data.price);
if (($('#product_id').val().length > 0) || ($('#select_type').val() >= 0)) {
$('#savelinebutton').removeAttr('disabled');
} else {
$('#savelinebutton').attr('disabled','disabled');
}
} else {
$('#price_ht').val('');
$('#savelinebutton').attr('disabled','disabled');
}
}, 'json');
}
});
$('#tva_tx').change(function() {
$.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', {
'action': 'get_ttc',
'pu_ht': $('#price_ht').val(),
'tva_tx': $(this).val()
},
function(data) {
if (data && data.price.length > 0) {
$('#price_ttc').val(data.price);
}
}, 'json');
});
<?php if (! empty($conf->margin->enabled)) { ?>
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product; ?>}, function(data) {
if (data.length > 0) {
var options = '';
var trouve=false;
$(data).each(function() {
options += '<option value="'+this.id+'" price="'+this.price+'"';
<?php if ($line->fk_fournprice > 0) { ?>
if (this.id == <?php echo $line->fk_fournprice; ?>) {
options += ' selected';
$("#buying_price").val(this.price);
trouve = true;
}
<?php } ?>
options += '>'+this.label+'</option>';
});
options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>';
$("#fournprice").html(options);
if (trouve) {
$("#buying_price").hide();
$("#fournprice").show();
} else {
$("#buying_price").show();
}
$("#fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#buying_price").val(selval).hide();
else
$('#buying_price').show();
});
} else {
$("#fournprice").hide();
$('#buying_price').show();
}
}, 'json');
<?php } ?>
});
</script>
<!-- END PHP TEMPLATE objectline_edit.tpl.php -->

View File

@@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
*/ */
?> ?>
<!-- BEGIN PHP TEMPLATE freeproductline_view.tpl.php --> <!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->
<tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>> <tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>>
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?> <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<td align="center"><?php echo ($i+1); ?></td> <td align="center"><?php echo ($i+1); ?></td>
@@ -60,19 +60,35 @@
} }
else else
{ {
if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); if ($line->fk_product > 0) {
if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product'); echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
// Show range
print_date_range($line->date_start, $line->date_end);
// Add description in form
if ($conf->global->PRODUIT_DESC_IN_FORM)
{
print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
}
if (! empty($line->label)) {
$text.= ' <strong>'.$line->label.'</strong>';
echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
} else { } else {
echo $text.' '.dol_htmlentitiesbr($line->description);
}
// Show range if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
print_date_range($line->date_start,$line->date_end); if ($type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
if (! empty($line->label)) {
$text.= ' <strong>'.$line->label.'</strong>';
echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
} else {
echo $text.' '.dol_htmlentitiesbr($line->description);
}
// Show range
print_date_range($line->date_start,$line->date_end);
}
} }
?> ?>
</td> </td>
@@ -148,4 +164,4 @@
<?php } ?> <?php } ?>
</tr> </tr>
<!-- END PHP TEMPLATE freeproductline_view.tpl.php --> <!-- END PHP TEMPLATE objectline_view.tpl.php -->

View File

@@ -1,183 +0,0 @@
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Need to have following variables defined:
* $conf
* $langs
* $dateSelector
* $this (invoice, order, ...)
* $line defined
*/
?>
<!-- BEGIN PHP TEMPLATE predefinedproductline_create.tpl.php -->
<tr class="liste_titre nodrag nodrop">
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="3"' : ' colspan="2"'); ?>>
<?php
echo $langs->trans("AddNewLine").' - ';
if ($conf->service->enabled)
echo $langs->trans('RecordedProductsAndServices');
else
echo $langs->trans('RecordedProducts');
?>
</td>
<td align="right"><?php echo $langs->trans('PriceUHT'); ?></td>
<td align="right"><?php echo $langs->trans('PriceUTTC'); ?></td>
<td align="right"><?php echo $langs->trans('Qty'); ?></td>
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
<?php
$colspan = 4;
if (! empty($conf->margin->enabled)) {
?>
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php
if($conf->global->DISPLAY_MARGIN_RATES)
$colspan++;
if($conf->global->DISPLAY_MARK_RATES)
$colspan++;
}
?>
<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
</tr>
<form name="addpredefinedproduct" id="addpredefinedproduct" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="action" value="addline" />
<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#idprod').change(function() {
jQuery('#dp_desc').focus();
});
});
</script>
<tr <?php echo $bcnd[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="3"' : ' colspan="2"'); ?>>
<?php
$ajaxoptions=array(
'update' => array(
'dp_price_ht' => 'price_ht',
'dp_price_ttc' => 'price_ttc'
)
);
$form->select_produits('', 'idprod', '', $conf->product->limit_size, $buyer->price_level, 1, 2, '', 0, $ajaxoptions);
if (is_object($hookmanager))
{
$parameters=array('fk_parent_line'=>$_POST["fk_parent_line"]);
$reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action);
}
// Editor 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;
$doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
?>
</td>
<td align="right"><input type="text" size="6" id="dp_price_ht" name="dp_price_ht" value="<?php echo (isset($_POST["dp_price_ht"])?$_POST["dp_price_ht"]:''); ?>"></td>
<td align="right"><input type="text" size="6" id="dp_price_ttc" name="dp_price_ttc" value="<?php echo (isset($_POST["dp_price_ttc"])?$_POST["dp_price_ttc"]:''); ?>"></td>
<td align="right"><input type="text" size="2" name="qty" value="1"></td>
<td align="right" nowrap="nowrap"><input type="text" size="1" name="remise_percent" value="<?php echo $buyer->remise_client; ?>">%</td>
<?php
$colspan = 4;
if (! empty($conf->margin->enabled)) {
?>
<td align="right">
<select id="dp_fournprice" name="dp_fournprice" style="display: none;"></select>
<input type="text" size="5" id="dp_buying_price" name="dp_buying_price" value="<?php echo (isset($_POST["dp_buying_price"])?$_POST["dp_buying_price"]:''); ?>">
</td>
<?php
if($conf->global->DISPLAY_MARGIN_RATES)
$colspan++;
if($conf->global->DISPLAY_MARK_RATES)
$colspan++;
}
?>
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline"></td>
</tr>
<?php if (! empty($conf->service->enabled) && $dateSelector) {
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
$colspan = 10;
else
$colspan = 9;
if (! empty($conf->margin->enabled)) {
if($conf->global->DISPLAY_MARGIN_RATES)
$colspan++;
if($conf->global->DISPLAY_MARK_RATES)
$colspan++;
}
?>
<tr <?php echo $bcnd[$var]; ?>>
<td colspan="<?php echo $colspan; ?>">
<?php
echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' ';
echo $form->select_date('','date_start_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct");
echo ' '.$langs->trans('to').' ';
echo $form->select_date('','date_end_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct");
?>
</td>
</tr>
<?php } ?>
</form>
<?php
if (! empty($conf->margin->enabled)) {
?>
<script type="text/javascript">
$("#idprod").change(function() {
$("#np_fournprice options").remove();
$("#np_buying_price").show();
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) {
if (data.length > 0) {
var options = '';
var i = 0;
$(data).each(function() {
i++;
options += '<option value="'+this.id+'" price="'+this.price+'"';
if (i == 1) {
options += ' selected';
$("#np_buying_price").val(this.price);
}
options += '>'+this.label+'</option>';
});
options += '<option value=null><?php echo $langs->trans("InputPrice"); ?></option>';
$("#np_fournprice").html(options);
$("#np_buying_price").hide();
$("#np_fournprice").show();
$("#np_fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#np_buying_price").val(selval).hide();
else
$('#np_buying_price').show();
});
}
},
'json');
});
</script>
<?php } ?>
<!-- END PHP TEMPLATE predefinedproductline_create.tpl.php -->

View File

@@ -1,164 +0,0 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Need to have following variables defined:
* $conf
* $langs
* $dateSelector
* $this (invoice, order, ...)
* $line defined
*/
?>
<!-- BEGIN PHP TEMPLATE predefinedproductline_edit.tpl.php -->
<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
<input type="hidden" name="action" value="updateligne" />
<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
<input type="hidden" name="lineid" value="<?php echo $line->id; ?>" />
<tr <?php echo $bc[$var]; ?>>
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
<div id="<?php echo $line->id; ?>"></div>
<input type="hidden" name="productid" value="<?php echo $line->fk_product; ?>" />
<a href="<?php echo DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product; ?>">
<?php
if ($line->product_type==1) echo img_object($langs->trans('ShowService'),'service');
else print img_object($langs->trans('ShowProduct'),'product');
echo ' '.$line->ref;
?>
</a>
<?php
echo ' - '.nl2br($line->product_label);
echo '<br>';
if (is_object($hookmanager))
{
$fk_parent_line = ($_POST["fk_parent_line"] ? $_POST["fk_parent_line"] : $line->fk_parent_line);
$parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer);
$reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action);
}
// editeur wysiwyg
$nbrows=ROWS_2;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
$doleditor->Create();
?>
</td>
<td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,'',$line->info_bits); ?></td>
<td align="right">
<input size="6" type="text" class="flat" name="subprice" value="<?php echo price($line->subprice,0,'',0); ?>" />
</td>
<td align="right">
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="2" type="text" class="flat" name="qty" value="<?php echo $line->qty; ?>" />
<?php } else { ?> &nbsp; <?php } ?>
</td>
<td align="right" nowrap>
<?php if (($line->info_bits & 2) != 2) { ?>
<input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>" />%
<?php } else { ?>
&nbsp;
<?php } ?>
</td>
<?php
if (! empty($conf->margin->enabled)) {
?>
<td align="right">
<select id="fournprice" name="fournprice"></select>
<input type="text" size="5" id="buying_price" name="buying_price" style="display: none;" value="<?php echo price($line->pa_ht,0,'',0); ?>">
</td>
<?php
}
?>
<td align="center" colspan="5" valign="middle">
<input type="submit" class="button" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
<input type="submit" class="button" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
</td>
</tr>
<?php if ($conf->service->enabled && $dateSelector && $line->product_type == 1) { ?>
<tr <?php echo $bc[$var]; ?>>
<td colspan="9"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?>
<?php
echo $form->select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne");
echo ' '.$langs->trans('to').' ';
echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne");
?>
</td>
</tr>
<?php } ?></form>
<?php
if (! empty($conf->margin->enabled)) {
?>
<script type="text/javascript">
$(document).ready(function() {
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product; ?>}, function(data) {
if (data.length > 0) {
var options = '';
var trouve=false;
$(data).each(function() {
options += '<option value="'+this.id+'" price="'+this.price+'"';
<?php
if ($line->fk_fournprice > 0) {
?>
if (this.id == <?php echo $line->fk_fournprice; ?>) {
options += ' selected';
$("#buying_price").val(this.price);
trouve = true;
}
<?php
}
?>
options += '>'+this.label+'</option>';
});
options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>';
$("#fournprice").html(options);
if (trouve) {
$("#buying_price").hide();
$("#fournprice").show();
}
else {
$("#buying_price").show();
}
$("#fournprice").change(function() {
var selval = $(this).find('option:selected').attr("price");
if (selval)
$("#buying_price").val(selval).hide();
else
$('#buying_price').show();
});
}
else {
$("#fournprice").hide();
$('#buying_price').show();
}
},
'json');
});
</script>
<?php } ?>
<!-- END PHP TEMPLATE predefinedproductline_edit.tpl.php -->

View File

@@ -1,112 +0,0 @@
<?php
/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
?>
<!-- BEGIN PHP TEMPLATE predefinedproductline_view.tpl.php -->
<tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>>
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<td align="center"><?php echo ($i+1); ?></td>
<?php } ?>
<td><div id="<?php echo $line->id; ?>"></div>
<?php
echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):''));
// Show range
print_date_range($line->date_start, $line->date_end);
// Add description in form
if ($conf->global->PRODUIT_DESC_IN_FORM)
{
print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
}
?>
</td>
<td align="right" nowrap="nowrap"><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td>
<td align="right" nowrap="nowrap"><?php echo price($line->subprice); ?></td>
<td align="right" nowrap="nowrap">&nbsp;</td>
<td align="right" nowrap="nowrap">
<?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty;
else echo '&nbsp;'; ?>
</td>
<?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?>
<td align="right"><?php echo dol_print_reduction($line->remise_percent,$langs); ?></td>
<?php } else { ?>
<td>&nbsp;</td>
<?php }
if (! empty($conf->margin->enabled)) { ?>
<td align="right" nowrap="nowrap"><?php echo price($line->pa_ht); ?></td>
<?php if ($conf->global->DISPLAY_MARGIN_RATES) {?>
<td align="right" nowrap="nowrap"><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?></td>
<?php
}
if ($conf->global->DISPLAY_MARK_RATES) { ?>
<td align="right" nowrap="nowrap"><?php echo price($line->marque_tx).'%'; ?></td>
<?php } } ?>
<?php if ($line->special_code == 3) { ?>
<td align="right" nowrap="nowrap"><?php echo $langs->trans('Option'); ?></td>
<?php } else { ?>
<td align="right" nowrap="nowrap"><?php echo price($line->total_ht); ?></td>
<?php } ?>
<?php if ($this->statut == 0 && $user->rights->$element->creer) { ?>
<td align="center">
<?php if (($line->info_bits & 2) == 2) { ?>
<?php } else { ?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#'.$line->id; ?>">
<?php echo img_edit(); ?>
</a>
<?php } ?>
</td>
<td align="center">
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=ask_deleteline&amp;lineid='.$line->id; ?>">
<?php echo img_delete(); ?>
</a>
</td>
<?php if ($num > 1) { ?>
<td align="center" class="tdlineupdown">
<?php if ($i > 0) { ?>
<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=up&amp;rowid='.$line->id; ?>">
<?php echo img_up(); ?>
</a>
<?php } ?>
<?php if ($i < $num-1) { ?>
<a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=down&amp;rowid='.$line->id; ?>">
<?php echo img_down(); ?>
</a>
<?php } ?>
</td>
<?php } else { ?>
<td align="center" class="tdlineupdown">&nbsp;</td>
<?php } ?>
<?php } else { ?>
<td colspan="3">&nbsp;</td>
<?php } ?>
</tr>
<!-- END PHP TEMPLATE predefinedproductline_view.tpl.php -->