| Server IP : 162.214.74.102 / Your IP : 216.73.216.59 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/www/lrsys_apps/regional/application/plugins/modulo_fiscal/controllers/ |
Upload File : |
<?php
_auth();
$ui->assign('_application_menu', 'modulo_fiscal');
$ui->assign('_title', $_L['Fiscal Module'] . ' - ' . $config['CompanyName']);
$ui->assign('_st', $_L['Settings Company']);
$action = $routes['2'];
$user = User::_info();
$ui->assign('user', $user);
switch ($action) {
case 'company':
$dadosEmpresa = ORM::for_table('app_fiscal_config')->find_many();
foreach ($dadosEmpresa as $da) {
$r[$da['key']] = $da['value'];
}
$ui->assign('dataCompany', $r);
$c = ORM::for_table('city')->order_by_asc('city_name')->find_many();
$ui->assign('city', $c);
$e = ORM::for_table('state')->order_by_asc('state_name')->find_many();
$ui->assign('state', $e);
$css_arr = array('s2/css/select2.min', 'modal', 'dp/dist/datepicker.min', 'redactor/redactor');
$js_arr = array('redactor/redactor.min', 's2/js/select2.min', 's2/js/i18n/' . lan(), 'dp/dist/datepicker.min', 'dp/i18n/' . $config['language'], 'numeric', 'modal');
$ui->assign('xheader', Asset::css($css_arr));
$ui->assign('xfooter', Asset::js($js_arr) . Asset::js_external(APP_URL . "/application/plugins/modulo_fiscal/js/configuration.js"));
$ui->assign('_include', 'configuration');
// Wrap the Contents & Display The Page
$ui->display('wrapper.tpl');
break;
case 'company-post':
if ($_POST) {
$msg = "";
//validação de campos obrigatórios
if (empty(_post('company_name'))) {
$msg.=$_L['Company Name'] . $_L['is required'];
}
if (empty(_post('company_fantasy_name'))) {
$msg.=$_L['Fantasy Name'] . $_L['is required'];
}
if (empty(_post('company_cnpj'))) {
$msg.=$_L['CNPJ'] . $_L['is required'];
}
if (empty(_post('company_ie'))) {
$msg.=$_L['IE'] . $_L['is required'];
}
// if (empty(_post('company_iest'))) {
// $msg.=$_L['IEST'] . $_L['is required'];
// }
if (empty(_post('company_im'))) {
$msg.=$_L['IM'] . $_L['is required'];
}
// if (empty(_post('company_cnae'))) {
// $msg.=$_L['CNAE'] . $_L['is required'];
// }
if (empty(_post('company_crt'))) {
$msg.=$_L['CRT'] . $_L['is required'];
}
if (empty(_post('company_zip'))) {
$msg.=$_L['ZIP Postal Code'] . $_L['is required'];
}
if (empty(_post('company_state'))) {
$msg.=$_L['State Region'] . $_L['is required'];
}
if (empty(_post('company_city'))) {
$msg.=$_L['City'] . $_L['is required'];
}
if (empty($msg)) {
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_name')->find_one();
$d->value = _post('company_name');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_fantasy_name')->find_one();
$d->value = _post('company_fantasy_name');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_cnpj')->find_one();
$d->value = _post('company_cnpj');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_ie')->find_one();
$d->value = _post('company_ie');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_iest')->find_one();
$d->value = _post('company_iest');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_im')->find_one();
$d->value = _post('company_im');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_cnae')->find_one();
$d->value = _post('company_cnae');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_crt')->find_one();
$d->value = _post('company_crt');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_address')->find_one();
$d->value = _post('company_address');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_number')->find_one();
$d->value = _post('company_number');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_complement')->find_one();
$d->value = _post('company_complement');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_neighborhood')->find_one();
$d->value = _post('company_neighborhood');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_zip')->find_one();
$d->value = _post('company_zip');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_city_id')->find_one();
$d->value = _post('company_city');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_state_id')->find_one();
$d->value = _post('company_state');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'company_phone')->find_one();
$d->value = _post('company_phone');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_environment')->find_one();
$d->value = _post('note_environment');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'password_certificate')->find_one();
$d->value = _post('password_certificate');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_series_nfe')->find_one();
$d->value = _post('note_series_nfe');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_number_nfe')->find_one();
$d->value = _post('note_number_nfe');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_series_nfce')->find_one();
$d->value = _post('note_series_nfce');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_number_nfce')->find_one();
$d->value = _post('note_number_nfce');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_token_nfce_id')->find_one();
$d->value = _post('note_token_nfce_id');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_token_nfce')->find_one();
$d->value = _post('note_token_nfce');
$d->save();
$d = ORM::for_table('app_fiscal_config')->where('key', 'note_img_logo')->find_one();
//apaga o logo antigo
if (isset($_FILES["note_img_logo"]) && $_FILES["note_img_logo"]["name"] != '') {
if (!empty($d->value)) {
unlink('application/plugins/modulo_fiscal/empresa/images/' . $d->value);
}
$d->value = str_replace(" ", "_", preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities(trim($_FILES["note_img_logo"]["name"]))));
move_uploaded_file($_FILES["note_img_logo"]["tmp_name"], 'application/plugins/modulo_fiscal/empresa/images/' . $d->value);
$d->save();
}
$d = ORM::for_table('app_fiscal_config')->where('key', 'certificate')->find_one();
if (isset($_FILES["certificate"]) && $_FILES["certificate"]["name"] != '') {
if (!empty($d->value)) {
unlink('application/plugins/modulo_fiscal/empresa/certs/' . $d->value);
}
$d->value = str_replace(" ", "_", preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities(trim($_FILES["certificate"]["name"]))));
move_uploaded_file($_FILES["certificate"]["tmp_name"], 'application/plugins/modulo_fiscal/empresa/certs/' . $d->value);
$d->save();
}
_msglog('s', $_L['Configuration Edited Successfully']);
echo "OK";
} else {
echo $msg;
}
} else {
echo $_L['Not found'];
}
break;
default:
echo 'action not defined';
}