Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
60ad09db90
@ -2444,6 +2444,48 @@ abstract class CommonObject
|
|||||||
|
|
||||||
/* This is to show add lines */
|
/* This is to show add lines */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show add predefined 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'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
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false)
|
||||||
|
{
|
||||||
|
global $conf,$langs,$object;
|
||||||
|
global $form,$bcnd,$var;
|
||||||
|
|
||||||
|
// Use global variables + $dateSelector + $seller and $buyer
|
||||||
|
include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 Societe $seller Object thirdparty who sell
|
||||||
|
* @param Societe $buyer Object thirdparty who buy
|
||||||
|
* @param HookManager $hookmanager Hook manager instance
|
||||||
|
* @return void
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false)
|
||||||
|
{
|
||||||
|
global $conf,$langs,$object;
|
||||||
|
global $form,$bcnd,$var;
|
||||||
|
|
||||||
|
// Use global variables + $dateSelector + $seller and $buyer
|
||||||
|
include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show add free and predefined products/services form
|
* Show add free and predefined products/services form
|
||||||
|
|||||||
127
htdocs/core/tpl/freeproductline_create.tpl.php
Normal file
127
htdocs/core/tpl/freeproductline_create.tpl.php
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
<?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 freeproductline_create.tpl.php -->
|
||||||
|
<tr class="liste_titre nodrag nodrop">
|
||||||
|
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>><div id="add"></div><?php echo $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone"); ?></td>
|
||||||
|
<td align="right"><?php echo $langs->trans('VAT'); ?></td>
|
||||||
|
<td align="right"><?php echo $langs->trans('PriceUHT'); ?></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; ?>"> </td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<form name="addproduct" id="addproduct" 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; ?>" />
|
||||||
|
|
||||||
|
<tr <?php echo $bcnd[$var]; ?>>
|
||||||
|
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
|
||||||
|
<?php
|
||||||
|
echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1);
|
||||||
|
if (($conf->product->enabled && $conf->service->enabled) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '<br>';
|
||||||
|
|
||||||
|
if (is_object($hookmanager))
|
||||||
|
{
|
||||||
|
$parameters=array();
|
||||||
|
$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">
|
||||||
|
<?php
|
||||||
|
if ($buyer->tva_assuj == "0") echo '<input type="hidden" name="np_tva_tx" value="0">0';
|
||||||
|
else echo $form->load_tva('np_tva_tx', (isset($_POST["np_tva_tx"])?$_POST["np_tva_tx"]:-1), $seller, $buyer);
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td align="right"><input type="text" size="5" name="np_price" value="<?php echo (isset($_POST["np_price"])?$_POST["np_price"]:''); ?>"></td>
|
||||||
|
<td align="right"><input type="text" size="2" name="qty" value="<?php echo (isset($_POST["qty"])?$_POST["qty"]:1); ?>"></td>
|
||||||
|
<td align="right" nowrap><input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" name="remise_percent">%</td>
|
||||||
|
<?php
|
||||||
|
$colspan = 4;
|
||||||
|
if (! empty($conf->margin->enabled)) {
|
||||||
|
?>
|
||||||
|
<td align="right"><input type="text" size="5" name="np_buying_price" value="<?php echo (isset($_POST["np_buying_price"])?$_POST["np_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 ($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',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
|
||||||
|
echo ' '.$langs->trans('to').' ';
|
||||||
|
echo $form->select_date('','date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addproduct");
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<!-- END PHP TEMPLATE freeproductline_create.tpl.php -->
|
||||||
101
htdocs/core/tpl/freeproductline_edit.tpl.php
Normal file
101
htdocs/core/tpl/freeproductline_edit.tpl.php
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
<?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 { ?>
|
||||||
|
|
||||||
|
<?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 { ?>
|
||||||
|
|
||||||
|
<?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 -->
|
||||||
142
htdocs/core/tpl/freeproductline_view.tpl.php
Normal file
142
htdocs/core/tpl/freeproductline_view.tpl.php
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?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 freeproductline_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->rowid; ?>"></div>
|
||||||
|
<?php if (($line->info_bits & 2) == 2) { ?>
|
||||||
|
<a href="<?php echo DOL_URL_ROOT.'/comm/remx.php?id='.$this->socid; ?>">
|
||||||
|
<?php
|
||||||
|
$txt='';
|
||||||
|
print img_object($langs->trans("ShowReduc"),'reduc').' ';
|
||||||
|
if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit");
|
||||||
|
//else $txt=$langs->trans("Discount");
|
||||||
|
print $txt;
|
||||||
|
?>
|
||||||
|
</a>
|
||||||
|
<?php
|
||||||
|
if ($line->description)
|
||||||
|
{
|
||||||
|
if ($line->description == '(CREDIT_NOTE)')
|
||||||
|
{
|
||||||
|
$discount=new DiscountAbsolute($this->db);
|
||||||
|
$discount->fetch($line->fk_remise_except);
|
||||||
|
echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
|
||||||
|
}
|
||||||
|
elseif ($line->description == '(DEPOSIT)')
|
||||||
|
{
|
||||||
|
$discount=new DiscountAbsolute($this->db);
|
||||||
|
$discount->fetch($line->fk_remise_except);
|
||||||
|
echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
|
||||||
|
// Add date of deposit
|
||||||
|
if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo ($txt?' - ':'').dol_htmlentitiesbr($line->description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow');
|
||||||
|
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||||
|
else $text = img_object($langs->trans('Product'),'product');
|
||||||
|
echo $text.' '.dol_htmlentitiesbr($line->description);
|
||||||
|
// Show range
|
||||||
|
print_date_range($line->date_start,$line->date_end);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</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">
|
||||||
|
<?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty;
|
||||||
|
else echo ' '; ?>
|
||||||
|
</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> </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.'&action=editline&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.'&action=ask_deleteline&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.'&action=up&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.'&action=down&rowid='.$line->id; ?>">
|
||||||
|
<?php echo img_down(); ?>
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
|
<?php } else { ?>
|
||||||
|
<td align="center" class="tdlineupdown"> </td>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } else { ?>
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<!-- END PHP TEMPLATE freeproductline_view.tpl.php -->
|
||||||
@ -218,7 +218,7 @@ $(document).ready(function() {
|
|||||||
$('#service_duration_area').hide();
|
$('#service_duration_area').hide();
|
||||||
|
|
||||||
$('#idprod').change(function() {
|
$('#idprod').change(function() {
|
||||||
if ($(this).val().length > 0) {
|
if ($(this).val() > 0) {
|
||||||
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
if (typeof CKEDITOR == 'object' && typeof CKEDITOR.instances != 'undefined' && CKEDITOR.instances['product_desc'] != 'undefined') {
|
||||||
// We use CKEditor
|
// We use CKEditor
|
||||||
CKEDITOR.instances['product_desc'].focus();
|
CKEDITOR.instances['product_desc'].focus();
|
||||||
@ -226,9 +226,46 @@ $(document).ready(function() {
|
|||||||
// We use a simple textarea
|
// We use a simple textarea
|
||||||
$('#product_desc').focus();
|
$('#product_desc').focus();
|
||||||
}
|
}
|
||||||
|
// For compatibility with combobox
|
||||||
|
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
||||||
|
$.post('<?php echo DOL_URL_ROOT; ?>/product/ajax/products.php', {
|
||||||
|
'action': 'fetch',
|
||||||
|
'id': $(this).val(),
|
||||||
|
'price_level': <?php echo $buyer->price_level; ?>
|
||||||
|
},
|
||||||
|
function(data) {
|
||||||
|
if (typeof data != 'undefined') {
|
||||||
|
$('#select_type').val(data.type).attr('disabled','disabled');
|
||||||
|
$('#product_ref').val(data.ref);
|
||||||
|
$('#product_label').val(data.label).attr('disabled','disabled');
|
||||||
|
$('#origin_label_cache').val(data.label);
|
||||||
|
$('#origin_desc_cache').val(data.desc);
|
||||||
|
$('#price_base_type').val(data.pricebasetype);
|
||||||
|
$('#price_ht').val(data.price_ht).attr('disabled','disabled');
|
||||||
|
$('#origin_price_ht_cache').val(data.price_ht);
|
||||||
|
$('#update_label_area').show().trigger('show');
|
||||||
|
$('#update_desc_area').show().trigger('show');
|
||||||
|
$('#update_price_area').show().trigger('show');
|
||||||
|
}
|
||||||
|
}, 'json');
|
||||||
|
<?php } ?>
|
||||||
} else {
|
} else {
|
||||||
$('#update_desc_checkbox').removeAttr('checked').trigger('change');
|
$('#update_desc_checkbox').removeAttr('checked').trigger('change');
|
||||||
$('#update_price_checkbox').removeAttr('checked').trigger('change');
|
$('#update_price_checkbox').removeAttr('checked').trigger('change');
|
||||||
|
// For compatibility with combobox
|
||||||
|
<?php if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { ?>
|
||||||
|
$('#select_type').val('').removeAttr('disabled');
|
||||||
|
$('#product_ref').val('');
|
||||||
|
$('#product_label').val('').removeAttr('disabled');
|
||||||
|
$('#origin_label_cache').val('');
|
||||||
|
$('#origin_desc_cache').val('');
|
||||||
|
$('#price_base_type').val('');
|
||||||
|
$('#price_ht').val('').removeAttr('disabled');
|
||||||
|
$('#origin_price_ht_cache').val('');
|
||||||
|
$('#update_label_area').hide().trigger('hide');
|
||||||
|
$('#update_desc_area').hide().trigger('hide');
|
||||||
|
$('#update_price_area').hide().trigger('hide');
|
||||||
|
<?php } ?>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
173
htdocs/core/tpl/predefinedproductline_create.tpl.php
Normal file
173
htdocs/core/tpl/predefinedproductline_create.tpl.php
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
<?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="4"' : ' colspan="3"'); ?>>
|
||||||
|
<?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('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; ?>"> </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('#np_desc').focus();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<tr <?php echo $bcnd[$var]; ?>>
|
||||||
|
<td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="4"' : ' colspan="3"'); ?>>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$form->select_produits('','idprod','',$conf->product->limit_size,$buyer->price_level);
|
||||||
|
|
||||||
|
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('np_desc',$_POST["np_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70);
|
||||||
|
$doleditor->Create();
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td align="right"><input type="text" size="2" name="qty" value="1"></td>
|
||||||
|
<td align="right" 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="np_fournprice" name="np_fournprice" style="display: none;"></select>
|
||||||
|
<input type="text" size="5" id="np_buying_price" name="np_buying_price" value="<?php echo (isset($_POST["np_buying_price"])?$_POST["np_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 -->
|
||||||
164
htdocs/core/tpl/predefinedproductline_edit.tpl.php
Normal file
164
htdocs/core/tpl/predefinedproductline_edit.tpl.php
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
<?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 { ?> <?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 { ?>
|
||||||
|
|
||||||
|
<?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 -->
|
||||||
111
htdocs/core/tpl/predefinedproductline_view.tpl.php
Normal file
111
htdocs/core/tpl/predefinedproductline_view.tpl.php
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
<?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 ($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">
|
||||||
|
<?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty;
|
||||||
|
else echo ' '; ?>
|
||||||
|
</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> </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.'&action=editline&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.'&action=ask_deleteline&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.'&action=up&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.'&action=down&rowid='.$line->id; ?>">
|
||||||
|
<?php echo img_down(); ?>
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
</td>
|
||||||
|
<?php } else { ?>
|
||||||
|
<td align="center" class="tdlineupdown"> </td>
|
||||||
|
<?php } ?>
|
||||||
|
<?php } else { ?>
|
||||||
|
<td colspan="3"> </td>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<!-- END PHP TEMPLATE predefinedproductline_view.tpl.php -->
|
||||||
@ -31,10 +31,6 @@ if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
|||||||
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
|
||||||
|
|
||||||
$langs->load("products");
|
|
||||||
$langs->load("main");
|
|
||||||
|
|
||||||
$htmlname=GETPOST('htmlname','alpha');
|
$htmlname=GETPOST('htmlname','alpha');
|
||||||
$socid=GETPOST('socid','int');
|
$socid=GETPOST('socid','int');
|
||||||
@ -43,50 +39,105 @@ $mode=GETPOST('mode','int');
|
|||||||
$status=((GETPOST('status','int') >= 0) ? GETPOST('status','int') : -1);
|
$status=((GETPOST('status','int') >= 0) ? GETPOST('status','int') : -1);
|
||||||
$outjson=(GETPOST('outjson','int') ? GETPOST('outjson','int') : 0);
|
$outjson=(GETPOST('outjson','int') ? GETPOST('outjson','int') : 0);
|
||||||
$pricelevel=GETPOST('price_level','int');
|
$pricelevel=GETPOST('price_level','int');
|
||||||
|
$action=GETPOST('action', 'alpha');
|
||||||
|
$id=GETPOST('id', 'int');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Ajout directives pour resoudre bug IE
|
|
||||||
//header('Cache-Control: Public, must-revalidate');
|
|
||||||
//header('Pragma: public');
|
|
||||||
|
|
||||||
//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
|
|
||||||
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";
|
||||||
|
|
||||||
//print '<body class="nocellnopadd">'."\n";
|
|
||||||
|
|
||||||
dol_syslog(join(',',$_GET));
|
dol_syslog(join(',',$_GET));
|
||||||
//print_r($_GET);
|
//print_r($_GET);
|
||||||
|
|
||||||
if (empty($htmlname)) return;
|
if (! empty($action) && $action == 'fetch' && ! empty($id))
|
||||||
|
|
||||||
$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET));
|
|
||||||
sort($match);
|
|
||||||
$idprod = (! empty($match[0]) ? $match[0] : '');
|
|
||||||
|
|
||||||
if (! GETPOST($htmlname) && ! GETPOST($idprod)) return;
|
|
||||||
|
|
||||||
// When used from jQuery, the search term is added as GET param "term".
|
|
||||||
$searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):''));
|
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
if (empty($mode) || $mode == 1)
|
|
||||||
{
|
{
|
||||||
$arrayresult=$form->select_produits_do("",$htmlname,$type,"",$pricelevel,$searchkey,$status,2,$outjson);
|
require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||||
|
|
||||||
|
$outjson=array();
|
||||||
|
|
||||||
|
$object = new Product($db);
|
||||||
|
$ret=$object->fetch($id);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
$outref=$object->ref;
|
||||||
|
$outlabel=$object->label;
|
||||||
|
$outdesc=$object->description;
|
||||||
|
$outtype=$object->type;
|
||||||
|
|
||||||
|
$found=false;
|
||||||
|
|
||||||
|
// Multiprice
|
||||||
|
if ($price_level >= 1) // If we need a particular price level (from 1 to 6)
|
||||||
|
{
|
||||||
|
$sql= "SELECT price, price_ttc, price_base_type ";
|
||||||
|
$sql.= "FROM ".MAIN_DB_PREFIX."product_price ";
|
||||||
|
$sql.= "WHERE fk_product='".$id."'";
|
||||||
|
$sql.= " AND price_level=".$price_level;
|
||||||
|
$sql.= " ORDER BY date_price";
|
||||||
|
$sql.= " DESC LIMIT 1";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
$objp = $this->db->fetch_object($result);
|
||||||
|
if ($objp)
|
||||||
|
{
|
||||||
|
$found=true;
|
||||||
|
$outprice_ht=price($objp->price);
|
||||||
|
$outprice_ttc=price($objp->price_ttc);
|
||||||
|
$outpricebasetype=$objp->price_base_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $found)
|
||||||
|
{
|
||||||
|
$outprice_ht=price($object->price);
|
||||||
|
$outprice_ttc=price($object->price_ttc);
|
||||||
|
$outpricebasetype=$object->price_base_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
$outjson = array('ref'=>$outref, 'label'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($outjson);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($mode == 2)
|
else
|
||||||
{
|
{
|
||||||
$arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson);
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||||||
|
|
||||||
|
$langs->load("products");
|
||||||
|
$langs->load("main");
|
||||||
|
|
||||||
|
top_httphead();
|
||||||
|
|
||||||
|
if (empty($htmlname)) return;
|
||||||
|
|
||||||
|
$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET));
|
||||||
|
sort($match);
|
||||||
|
$idprod = (! empty($match[0]) ? $match[0] : '');
|
||||||
|
|
||||||
|
if (! GETPOST($htmlname) && ! GETPOST($idprod)) return;
|
||||||
|
|
||||||
|
// When used from jQuery, the search term is added as GET param "term".
|
||||||
|
$searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):''));
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
if (empty($mode) || $mode == 1)
|
||||||
|
{
|
||||||
|
$arrayresult=$form->select_produits_do("",$htmlname,$type,"",$pricelevel,$searchkey,$status,2,$outjson);
|
||||||
|
}
|
||||||
|
elseif ($mode == 2)
|
||||||
|
{
|
||||||
|
$arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson);
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
if ($outjson) print json_encode($arrayresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
if ($outjson) print json_encode($arrayresult);
|
|
||||||
|
|
||||||
//print "</body>";
|
|
||||||
//print "</html>";
|
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user