Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
6c9d6eda56
@ -115,7 +115,8 @@ class HookManager
|
||||
* @param Object &$object Object to use hooks on
|
||||
* @param string &$action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...)
|
||||
* @return mixed For doActions,formObjectOptions: Return 0 if we want to keep standard actions, >0 if if want to stop standard actions, <0 means KO.
|
||||
* For printSearchForm,printLeftBlock,printTopRightMenu,...: Return HTML string.
|
||||
* For printSearchForm,printLeftBlock,printTopRightMenu,formAddObjectLine,...: Return HTML string. TODO Must always return an int and things to print into ->resprints.
|
||||
* Can also return some values into an array ->results.
|
||||
* $this->error or this->errors are also defined by class called by this function if error.
|
||||
*/
|
||||
function executeHooks($method, $parameters=false, &$object='', &$action='')
|
||||
@ -127,45 +128,58 @@ class HookManager
|
||||
|
||||
// Loop on each hook to qualify modules that declared context
|
||||
$modulealreadyexecuted=array();
|
||||
$resaction=0; $resprint='';
|
||||
$resaction=0; $error=0;
|
||||
$this->resPrint=''; $this->resArray=array();
|
||||
foreach($this->hooks as $modules) // this->hooks is an array with context as key and value is an array of modules that handle this context
|
||||
{
|
||||
if (! empty($modules))
|
||||
{
|
||||
foreach($modules as $module => $actionclassinstance)
|
||||
{
|
||||
// test to avoid to run twice a hook, when a module implements several active contexts
|
||||
// jump to next class if method does not exists
|
||||
if (! method_exists($actionclassinstance,$method)) continue;
|
||||
// test to avoid to run twice a hook, when a module implements several active contexts
|
||||
if (in_array($module,$modulealreadyexecuted)) continue;
|
||||
$modulealreadyexecuted[$module]=$module;
|
||||
|
||||
// Hooks that return int
|
||||
if (($method == 'doActions' || $method == 'formObjectOptions') && method_exists($actionclassinstance,$method))
|
||||
if (($method == 'doActions' || $method == 'formObjectOptions'))
|
||||
{
|
||||
$resaction+=$actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
||||
if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
|
||||
{
|
||||
$this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
|
||||
if ($method == 'doActions')
|
||||
{
|
||||
if ($action=='add') $action='create'; // TODO this change must be inside the doActions
|
||||
if ($action=='update') $action='edit'; // TODO this change must be inside the doActions
|
||||
}
|
||||
}
|
||||
$resaction+=$actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
||||
if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
|
||||
{
|
||||
$error++;
|
||||
$this->error=$actionclassinstance->error; $this->errors=array_merge($this->errors, (array) $actionclassinstance->errors);
|
||||
// TODO remove this. Change must be inside the method if required
|
||||
if ($method == 'doActions')
|
||||
{
|
||||
if ($action=='add') $action='create';
|
||||
if ($action=='update') $action='edit';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Generic hooks that return a string (printSearchForm, printLeftBlock, formBuilddocOptions, ...)
|
||||
else if (method_exists($actionclassinstance,$method))
|
||||
// Generic hooks that return a string (printSearchForm, printLeftBlock, printTopRightMenu, formAddObjectLine, formBuilddocOptions, ...)
|
||||
else
|
||||
{
|
||||
if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
|
||||
// TODO. this should be done into the method by returning nothing
|
||||
if (is_array($parameters) && ! empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) continue;
|
||||
|
||||
$result = $actionclassinstance->$method($parameters, $object, $action, $this);
|
||||
if (is_array($result)) $this->resArray = array_merge($this->resArray, $result);
|
||||
else $resprint.=$result;
|
||||
|
||||
if (is_array($actionclassinstance->results)) $this->resArray =array_merge($this->resArray, $actionclassinstance->results);
|
||||
if (! empty($actionclassinstance->resprints)) $this->resPrint.=$actionclassinstance->resprints;
|
||||
|
||||
// TODO. remove this. array result must be set into $actionclassinstance->results
|
||||
if (is_array($result)) $this->resArray = array_merge($this->resArray, $result);
|
||||
// TODO. remove this. result must not be a string. we must use $actionclassinstance->resprint to return a string
|
||||
if (! is_array($result) && ! is_numeric($result)) $this->resPrint.=$result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($method == 'doActions' || $method == 'formObjectOptions') return $resaction;
|
||||
return $resprint;
|
||||
if ($method != 'doActions' && $method != 'formObjectOptions') return $this->resPrint; // TODO remove this. When there is something to print, ->resPrint is filled.
|
||||
return ($error?-1:$resaction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1447,7 +1447,8 @@ class Form
|
||||
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$outselect.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">';
|
||||
//$outselect.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">'; // remove select to have id same with combo and ajax
|
||||
$outselect.='<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
if (! $selected) $outselect.='<option value="0" selected="selected"> </option>';
|
||||
else $outselect.='<option value="0"> </option>';
|
||||
|
||||
|
||||
@ -49,8 +49,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
|
||||
// Remove product id before select another product
|
||||
// use keyup instead change to avoid loosing the product id
|
||||
$("input#search_'.$htmlname.'").keyup(function() {
|
||||
$("#'.$htmlname.'").val("").trigger("change");
|
||||
$("input#search_'.$htmlname.'").keydown(function() {
|
||||
//console.log(\'purge_id_after_keydown\');
|
||||
$("#'.$htmlname.'").val("");
|
||||
});
|
||||
$("input#search_'.$htmlname.'").change(function() {
|
||||
//console.log(\'keyup\');
|
||||
$("#'.$htmlname.'").trigger("change");
|
||||
});
|
||||
// Check when keyup
|
||||
$("input#search_'.$htmlname.'").onDelayedKeyup({ handler: function() {
|
||||
@ -116,6 +121,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
dataType: "json",
|
||||
minLength: '.$minLength.',
|
||||
select: function( event, ui ) {
|
||||
//console.log(\'set value of id with \'+ui.item.id);
|
||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change");
|
||||
// Disable an element
|
||||
if (options.option_disabled) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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
|
||||
@ -42,15 +42,14 @@
|
||||
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
|
||||
<?php
|
||||
$colspan = 4;
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
if (! empty($conf->margin->enabled))
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
?>
|
||||
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
$colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
$colspan++;
|
||||
}
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td colspan="<?php echo $colspan; ?>"> </td>
|
||||
</tr>
|
||||
@ -63,7 +62,7 @@ if (! empty($conf->margin->enabled)) {
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#idprod').change(function() {
|
||||
jQuery('#np_desc').focus();
|
||||
if (jQuery('#idprod').val() > 0) jQuery('#np_desc').focus();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -97,17 +96,16 @@ jQuery(document).ready(function() {
|
||||
<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)) {
|
||||
if (! empty($conf->margin->enabled))
|
||||
{
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
?>
|
||||
<td align="right">
|
||||
<select id="fournprice" name="fournprice" style="display: none;"></select>
|
||||
<input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (isset($_POST["buying_price"])?$_POST["buying_price"]:''); ?>">
|
||||
</td>
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
$colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
$colspan++;
|
||||
}
|
||||
?>
|
||||
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>">
|
||||
@ -115,18 +113,17 @@ if (! empty($conf->margin->enabled)) {
|
||||
</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)) {
|
||||
$colspan++; // For the buying price
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
$colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
$colspan++;
|
||||
}
|
||||
<?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))
|
||||
{
|
||||
$colspan++; // For the buying price
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
}
|
||||
?>
|
||||
<tr <?php echo $bcnd[$var]; ?>>
|
||||
<td colspan="<?php echo $colspan; ?>">
|
||||
@ -138,11 +135,15 @@ if (! empty($conf->margin->enabled)) {
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (! empty($conf->margin->enabled)) {
|
||||
if (! empty($conf->margin->enabled))
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$("#idprod").change(function() {
|
||||
@ -177,5 +178,7 @@ $("#idprod").change(function() {
|
||||
'json');
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<!-- END PHP TEMPLATE predefinedproductline_create.tpl.php -->
|
||||
|
||||
@ -1461,12 +1461,22 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// TODO Use the predefinedproductline_create.tpl.php file
|
||||
|
||||
// Add free products/services form
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'#add" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addline">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
|
||||
print '<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery(\'#idprodfournprice\').change(function() {
|
||||
if (jQuery(\'#idprodfournprice\').val() > 0) jQuery(\'#np_desc\').focus();
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
$var=true;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
|
||||
@ -1814,10 +1814,20 @@ else
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
// TODO Use the predefinedproductline_create.tpl.php file
|
||||
print '<form name="addline_predef" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addline" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="socid" value="'. $object->socid .'">';
|
||||
print '<input type="hidden" name="facid" value="'.$object->id.'">';
|
||||
|
||||
print '<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery(\'#idprodfournprice\').change(function() {
|
||||
if (jQuery(\'#idprodfournprice\').val() > 0) jQuery(\'#np_desc\').focus();
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
$var=! $var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="4">';
|
||||
|
||||
@ -1121,7 +1121,7 @@ else
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Name
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans('ThirdPartyName').'</span></td><td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="'.$object->name.'"></td></tr>';
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans('ThirdPartyName').'</span></td><td colspan="3"><input type="text" size="40" maxlength="60" name="nom" value="'.dol_escape_htmltag($object->name).'"></td></tr>';
|
||||
|
||||
// Prefix
|
||||
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||
@ -1130,12 +1130,12 @@ else
|
||||
// It does not change the prefix mode using the auto numbering prefix
|
||||
if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm)
|
||||
{
|
||||
print '<input type="hidden" name="prefix_comm" value="'.$object->prefix_comm.'">';
|
||||
print '<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">';
|
||||
print $object->prefix_comm;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" size="5" maxlength="5" name="prefix_comm" value="'.$object->prefix_comm.'">';
|
||||
print '<input type="text" size="5" maxlength="5" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user