Task #0002402: TVA : préférence , permettre de choisir l'ID ou le code
This commit is contained in:
parent
83f1ce1bb4
commit
d39ac28002
6 changed files with 67 additions and 3 deletions
|
|
@ -37,6 +37,8 @@ $g_parameter=new Noalyss_Parameter_Folder($cn);
|
|||
$g_user=new Noalyss_user($cn);
|
||||
$g_user->check(true);
|
||||
IDate::set_firstDate($g_user->get_first_week_day());
|
||||
ITva_Popup::set_vat_code($g_user->get_vat_code_preference());
|
||||
|
||||
set_language();
|
||||
/* if a code has been asked */
|
||||
if (isset($_REQUEST['plugin_code']) )
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ else
|
|||
}
|
||||
|
||||
IDate::set_firstDate($g_user->get_first_week_day());
|
||||
ITva_Popup::set_vat_code($g_user->get_vat_code_preference());
|
||||
|
||||
// For progress bar, for saving time , we check and answer directly
|
||||
if ($op == "progressBar") {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,9 @@ $cn = Dossier::connect();
|
|||
global $g_user, $cn,$g_parameter,$http;
|
||||
$g_user = new Noalyss_user($cn);
|
||||
$http=new HttpInput();
|
||||
|
||||
IDate::set_firstDate($g_user->get_first_week_day());
|
||||
ITva_Popup::set_vat_code($g_user->get_vat_code_preference());
|
||||
|
||||
// check that the current user is saved into PostgreSQL setting in order to use it in PLPGSQL
|
||||
\Noalyss\Dbg::echo_var(1,sprintf("current user is [%s]",$cn->get_value("select current_setting('noalyss.user_login')")));
|
||||
|
|
|
|||
|
|
@ -192,6 +192,22 @@ if ( $action == 'display_form' )
|
|||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?=_('Utilisation id TVA ou code')?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$selVATCode=new ISelect('selVATCode');
|
||||
$selVATCode->value=array(
|
||||
['label'=>'numérique','value'=>0],
|
||||
['label'=>'Code','value'=>1]
|
||||
);
|
||||
$selVATCode->selected=$g_user->get_vat_code_preference();
|
||||
echo $selVATCode->input();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
|
|
@ -305,6 +321,7 @@ if ($action == 'save')
|
|||
$csv_decimal=$http->post("csv_decimal","number");
|
||||
$csv_encoding=$http->post("csv_encoding");
|
||||
$firstday=$http->post("selFirstDay","number");
|
||||
$vatCode=$http->post("selVATCode","number");
|
||||
$password="OK";
|
||||
$msg ="";
|
||||
if (noalyss_strlentrim($pass_1) != 0 && noalyss_strlentrim($pass_2) != 0)
|
||||
|
|
@ -344,6 +361,7 @@ if ($action == 'save')
|
|||
$g_user->save_global_preference('csv_decimal', $csv_decimal);
|
||||
$g_user->save_global_preference('csv_encoding', $csv_encoding);
|
||||
$g_user->save_global_preference('first_week_day', $firstday);
|
||||
$g_user->save_global_preference('vat_code', $vatCode);
|
||||
$g_user->save_email($p_email);
|
||||
|
||||
$_SESSION[SESSION_KEY.'g_theme']=$style_user;
|
||||
|
|
|
|||
|
|
@ -1819,7 +1819,8 @@ class Noalyss_User
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*@brief first day in calendar
|
||||
* @see IDate::set_firstDate(
|
||||
*/
|
||||
function get_first_week_day()
|
||||
{
|
||||
|
|
@ -1849,6 +1850,24 @@ class Noalyss_User
|
|||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*@brief Get preference , either the user see the numeric id for VAT or its code, if the preference doesn't exist
|
||||
* by default , 0 is saved in ACCOUNT_REPOSITORY
|
||||
* @see ITva_Popup::set_vat_code()
|
||||
* @see ITva_Popup
|
||||
*/
|
||||
function get_vat_code_preference():int
|
||||
{
|
||||
$repocn=new Database();
|
||||
$result=$repocn->get_value("select parameter_value from user_global_pref where parameter_type=$1 and user_id=$2 ",
|
||||
array("vat_code", $this->login));
|
||||
if ($repocn->count()==0)
|
||||
{
|
||||
$this->save_global_preference("vat_code", 0);
|
||||
return 0;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class ITva_Popup extends HtmlInput
|
|||
* by default it is 'popup_select_tva(this)';
|
||||
*/
|
||||
private $filter; //!< filter the VAT by ledger PURCHASE or SALE or NO FILTER, default=NO
|
||||
static $vat_code=0; //<! 0 show the numeric ID or 1 for CODE
|
||||
|
||||
public function __construct($p_name = null, $p_value = "", $p_id = "")
|
||||
{
|
||||
|
|
@ -129,9 +130,10 @@ class ITva_Popup extends HtmlInput
|
|||
// code is a span containing the label of the VAT (see add_label)
|
||||
if (isset($this->code)) {
|
||||
if ($this->cn != NULL) {
|
||||
$cnx=Dossier::connect();
|
||||
/* check if tva_id == integer */
|
||||
if (trim($this->value) != '' && isNumber($this->value) == 1 && strpos($this->value, ',') === false)
|
||||
$this->code->value = $this->cn->get_value('select tva_label from tva_rate where tva_id=$1',
|
||||
$this->code->value = $cnx->get_value('select tva_label from tva_rate where tva_id=$1',
|
||||
array($this->value));;
|
||||
}
|
||||
$this->set_attribute('jcode', $this->code->name);
|
||||
|
|
@ -139,7 +141,13 @@ class ITva_Popup extends HtmlInput
|
|||
|
||||
}
|
||||
$strAttribut = $this->get_node_attribute();
|
||||
|
||||
// show tva code
|
||||
if ( self::$vat_code == 1) {
|
||||
if ( isNumber($this->value ) == 1) {
|
||||
$cnx=Dossier::connect();
|
||||
$this->value=$cnx->get_value('select tva_code from tva_rate where tva_id=$1',[$this->value]);
|
||||
}
|
||||
}
|
||||
|
||||
$str = '<input type="TEXT" class="input_text" name="%s" value="%s" id="%s" placeholder="%s" size="6" %s %s
|
||||
list="dl_tva_%s" autocomplete="off">';
|
||||
|
|
@ -226,6 +234,19 @@ list="dl_tva_%s" autocomplete="off">';
|
|||
$this->code = new ISpan($p_code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief show the Numeric ID or the code
|
||||
* @param int $vat_code 0 for numeric , 1 for Code
|
||||
* @return void
|
||||
* @throws Exception if $vat_code is
|
||||
*/
|
||||
static function set_vat_code(int $vat_code)
|
||||
{
|
||||
if (isNumber($vat_code)==0){
|
||||
throw new Exception("VAT_CODE [{$vat_code}]: invalide data",EXC_INVALID);
|
||||
}
|
||||
self::$vat_code= $vat_code;
|
||||
}
|
||||
static public function test_me()
|
||||
{
|
||||
|
||||
|
|
@ -240,4 +261,5 @@ list="dl_tva_%s" autocomplete="off">';
|
|||
echo $tva->dbutton();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue