mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-16 11:30:55 +01:00
Ottimizzazzioni distribuite
Ottimizzazione della nuova funzione per l'individuazione dei percorsi personalizzati. Introduzione della validazione di email e VAT anche senza ApiLayer.
This commit is contained in:
parent
6d084f1d67
commit
4a1244c9a1
43
actions.php
43
actions.php
@ -8,8 +8,7 @@ if (!empty($id_plugin)) {
|
||||
|
||||
$directory = '/plugins/'.$info['directory'];
|
||||
$permesso = $info['idmodule_to'];
|
||||
$id_module = $info['idmodule_to'];
|
||||
|
||||
$id_module = $info['idmodule_to'];
|
||||
} else {
|
||||
$info = Modules::get($id_module);
|
||||
|
||||
@ -178,8 +177,7 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
'id_record' => $id_record,
|
||||
'id_plugin' => !empty($id_plugin) ? $id_plugin : null,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
$_SESSION['infos'][] = tr('File caricato correttamente!');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Errore durante il caricamento del file!');
|
||||
@ -221,7 +219,7 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
} elseif (filter('op') == 'send-email') {
|
||||
$template = Mail::getTemplate($post['template']);
|
||||
$id_account = $template['id_smtp'];
|
||||
|
||||
|
||||
// Elenco degli allegati
|
||||
$attachments = [];
|
||||
|
||||
@ -340,30 +338,18 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
}
|
||||
|
||||
if (Modules::getPermission($permesso) == 'r' || Modules::getPermission($permesso) == 'rw') {
|
||||
// Inclusione di eventuale plugin personalizzato
|
||||
if (!empty($info['script'])) {
|
||||
// Inclusione di eventuale plugin personalizzato
|
||||
if (file_exists(DOCROOT.'/modules/'.$info['module_dir'].'/plugins/custom/'.$info['script'])) {
|
||||
include DOCROOT.'/modules/'.$info['module_dir'].'/plugins/custom/'.$info['script'];
|
||||
} elseif (file_exists(DOCROOT.'/modules/'.$info['module_dir'].'/plugins/'.$info['script'])) {
|
||||
include DOCROOT.'/modules/'.$info['module_dir'].'/plugins/'.$info['script'];
|
||||
}
|
||||
include App::filepath('modules/'.$info['module_dir'].'/plugins|custom|', $info['script']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Caricamento helper modulo (verifico se ci sono helper personalizzati)
|
||||
if (file_exists(DOCROOT.$directory.'/custom/modutil.php')) {
|
||||
include_once DOCROOT.$directory.'/custom/modutil.php';
|
||||
} elseif (file_exists(DOCROOT.$directory.'/modutil.php')) {
|
||||
include_once DOCROOT.$directory.'/modutil.php';
|
||||
}
|
||||
include_once App::filepath($directory.'|custom|', 'modutil.php');
|
||||
|
||||
// Lettura risultato query del modulo
|
||||
if (file_exists(DOCROOT.$directory.'/custom/init.php')) {
|
||||
include DOCROOT.$directory.'/custom/init.php';
|
||||
} elseif (file_exists(DOCROOT.$directory.'/init.php')) {
|
||||
include DOCROOT.$directory.'/init.php';
|
||||
}
|
||||
include App::filepath($directory.'|custom|', 'init.php');
|
||||
|
||||
if (Modules::getPermission($permesso) == 'rw') {
|
||||
// Esecuzione delle operazioni di gruppo
|
||||
@ -372,23 +358,14 @@ if (Modules::getPermission($permesso) == 'r' || Modules::getPermission($permesso
|
||||
$id_records = array_filter($id_records, function ($var) {return !empty($var); });
|
||||
$id_records = array_unique($id_records);
|
||||
|
||||
$bulk = null;
|
||||
if (file_exists(DOCROOT.$directory.'/custom/bulk.php')) {
|
||||
$bulk = include DOCROOT.$directory.'/custom/bulk.php';
|
||||
} elseif (file_exists(DOCROOT.$directory.'/bulk.php')) {
|
||||
$bulk = include DOCROOT.$directory.'/bulk.php';
|
||||
}
|
||||
$bulk = (array) $bulk;
|
||||
$bulk = include App::filepath($directory.'|custom|', 'bulk.php');
|
||||
$bulk = empty($bulk) ? [] : $bulk;
|
||||
|
||||
if (in_array(post('op'), array_keys($bulk))) {
|
||||
redirect(ROOTDIR.'/controller.php?id_module='.$id_module, 'js');
|
||||
} else {
|
||||
// Esecuzione delle operazioni del modulo
|
||||
if (file_exists(DOCROOT.$directory.'/custom/actions.php')) {
|
||||
include DOCROOT.$directory.'/custom/actions.php';
|
||||
} elseif (file_exists(DOCROOT.$directory.'/actions.php')) {
|
||||
include DOCROOT.$directory.'/actions.php';
|
||||
}
|
||||
include App::filepath($directory.'|custom|', 'actions.php');
|
||||
|
||||
// Operazioni generiche per i campi personalizzati
|
||||
if (post('op') != null) {
|
||||
|
8
add.php
8
add.php
@ -72,17 +72,11 @@ $(document).ready(function(){
|
||||
echo '
|
||||
data.'.$key.' = "'.$value.'";';
|
||||
}
|
||||
|
||||
if (file_exists($docroot.$directory.'/custom/actions.php')) {
|
||||
$url = $rootdir.$directory.'/custom/actions.php';
|
||||
} elseif (file_exists($docroot.$directory.'/actions.php')) {
|
||||
$url = $rootdir.$directory.'/actions.php';
|
||||
}
|
||||
|
||||
echo '
|
||||
|
||||
$("#form_'.$id_module.'-'.$id_plugin.'").find("form").ajaxForm({
|
||||
url: "'.$url.'",
|
||||
url: globals.rootdir + "/actions.php",
|
||||
beforeSubmit: function(arr, $form, options) {
|
||||
return $form.parsley().validate();
|
||||
},
|
||||
|
@ -33,9 +33,11 @@
|
||||
"league/csv": "^8.2",
|
||||
"maximebf/debugbar": "^1.15",
|
||||
"monolog/monolog": "^1.22",
|
||||
"mpdf/mpdf": "^7.0",
|
||||
"mpdf/mpdf": "^7.1",
|
||||
"mpociot/vat-calculator": "^2.3",
|
||||
"paragonie/random_compat": "^2.0",
|
||||
"phpmailer/phpmailer": "^6.0",
|
||||
"respect/validation": "^1.1",
|
||||
"spipu/html2pdf": "^5.0",
|
||||
"symfony/filesystem": "^3.3",
|
||||
"symfony/finder": "^3.3",
|
||||
|
@ -146,11 +146,7 @@ if (empty($records)) {
|
||||
|
||||
// Pulsanti personalizzati
|
||||
ob_start();
|
||||
if (file_exists($docroot.'/modules/'.$module_dir.'/custom/buttons.php')) {
|
||||
include $docroot.'/modules/'.$module_dir.'/custom/buttons.php';
|
||||
} elseif (file_exists($docroot.'/modules/'.$module_dir.'/buttons.php')) {
|
||||
include $docroot.'/modules/'.$module_dir.'/buttons.php';
|
||||
}
|
||||
include Modules::filepath($id_module, 'buttons.php');
|
||||
$buttons = ob_get_clean();
|
||||
|
||||
if (!empty($buttons)) {
|
||||
|
@ -265,6 +265,7 @@ gulp.task('release', function () {
|
||||
'!./vendor/mpdf/mpdf/ttfonts/DejaVuinfo.txt',
|
||||
'!./vendor/mpdf/mpdf/ttfonts/DejaVu*Condensed*',
|
||||
'./vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/*',
|
||||
'./vendor/respect/validation/tests/*',
|
||||
]);
|
||||
|
||||
// Impostazione dello zip
|
||||
|
@ -6,13 +6,9 @@ include_once __DIR__.'/../core.php';
|
||||
if (!empty($id_plugin)) {
|
||||
$element = Plugins::get($id_plugin);
|
||||
|
||||
// Inclusione di eventuale plugin personalizzato
|
||||
if (!empty($element['script'])) {
|
||||
// Inclusione di eventuale plugin personalizzato
|
||||
if (file_exists($docroot.'/modules/'.$element['module_dir'].'/plugins/custom/'.$element['script'])) {
|
||||
include $docroot.'/modules/'.$element['module_dir'].'/plugins/custom/'.$element['script'];
|
||||
} elseif (file_exists($docroot.'/modules/'.$element['module_dir'].'/plugins/'.$element['script'])) {
|
||||
include $docroot.'/modules/'.$element['module_dir'].'/plugins/'.$element['script'];
|
||||
}
|
||||
include App::filepath('modules/'.$element['module_dir'].'/plugins|custom|', $element['script']);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -41,11 +37,7 @@ $total = App::readQuery($element);
|
||||
$module_options = (!empty($element['options2'])) ? $element['options2'] : $element['options'];
|
||||
|
||||
// Caricamento file aggiuntivo su elenco record
|
||||
if (file_exists($docroot.$directory.'/custom/controller_before.php')) {
|
||||
include $docroot.$directory.'/custom/controller_before.php';
|
||||
} elseif (file_exists($docroot.$directory.'/controller_before.php')) {
|
||||
include $docroot.$directory.'/controller_before.php';
|
||||
}
|
||||
include App::filepath($directory.'|custom|', 'controller_before.php');
|
||||
|
||||
if (count(Modules::getSegments($id_module)) > 1) {
|
||||
?>
|
||||
@ -204,8 +196,4 @@ elseif ($module_options == 'custom') {
|
||||
}
|
||||
|
||||
// Caricamento file aggiuntivo su elenco record
|
||||
if (file_exists($docroot.$directory.'/custom/controller_after.php')) {
|
||||
include $docroot.$directory.'/custom/controller_after.php';
|
||||
} elseif (file_exists($docroot.$directory.'/controller_after.php')) {
|
||||
include $docroot.$directory.'/controller_after.php';
|
||||
}
|
||||
include App::filepath($directory.'|custom|', 'controller_after.php');
|
||||
|
4819
locale/catalog.pot
4819
locale/catalog.pot
File diff suppressed because it is too large
Load Diff
@ -49,7 +49,7 @@ switch (post('op')) {
|
||||
'idlistino_vendite' => $post['idlistino_vendite'],
|
||||
'idiva_acquisti' => $post['idiva_acquisti'],
|
||||
'idiva_vendite' => $post['idiva_vendite'],
|
||||
'idbanca_acquisti' => $post['idbanca_acquisti'],
|
||||
'idbanca_acquisti' => $post['idbanca_acquisti'],
|
||||
'idbanca_vendite' => $post['idbanca_vendite'],
|
||||
'settore' => $post['settore'],
|
||||
'marche' => $post['marche'],
|
||||
@ -76,15 +76,10 @@ switch (post('op')) {
|
||||
|
||||
// Validazione della Partita IVA
|
||||
$check_vat_number = Validate::isValidVatNumber(strtoupper($post['piva']));
|
||||
// Se $check_vat_number non è null e la riposta è negativa --> mostro il messaggio di avviso.
|
||||
if ((!is_null($check_vat_number)) && (!$check_vat_number->valid)) {
|
||||
if (!empty($check_vat_number->error->info)) {
|
||||
$_SESSION['errors'][] = $check_vat_number->error->info;
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Attenzione: la partita IVA _IVA_ sembra non essere valida', [
|
||||
'_IVA_' => $post['piva'],
|
||||
]);
|
||||
}
|
||||
if (empty($check_vat_number)) {
|
||||
$_SESSION['errors'][] = tr('Attenzione: la partita IVA _IVA_ sembra non essere valida', [
|
||||
'_IVA_' => $post['piva'],
|
||||
]);
|
||||
}
|
||||
|
||||
// Aggiorno il codice anagrafica se non è già presente, altrimenti lo ignoro
|
||||
@ -264,15 +259,12 @@ switch (post('op')) {
|
||||
// Se l'anagrafica non è l'azienda principale, la disattivo
|
||||
if (!str_contains($records[0]['idtipianagrafica'], $id_azienda)) {
|
||||
$dbo->query('UPDATE an_anagrafiche SET deleted = 1 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module));
|
||||
|
||||
// Se l'anagrafica è collegata ad un utente lo disabilito
|
||||
$dbo->query('UPDATE zz_users SET enabled = 0 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module));
|
||||
|
||||
|
||||
|
||||
// Se l'anagrafica è collegata ad un utente lo disabilito
|
||||
$dbo->query('UPDATE zz_users SET enabled = 0 WHERE idanagrafica = '.prepare($id_record).Modules::getAdditionalsQuery($id_module));
|
||||
|
||||
$_SESSION['infos'][] = tr('Anagrafica eliminata!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -86,14 +86,7 @@ echo '
|
||||
<?php
|
||||
|
||||
// Variabili utilizzabili
|
||||
$module_dir = DOCROOT.'/modules/'.Modules::get($records[0]['id_module'])['directory'];
|
||||
$variables = [];
|
||||
|
||||
if (file_exists($module_dir.'/custom/variables.php')) {
|
||||
$variables = include $module_dir.'/custom/variables.php';
|
||||
} elseif (file_exists($module_dir.'/variables.php')) {
|
||||
$variables = include $module_dir.'/variables.php';
|
||||
}
|
||||
$variables = include Modules::filepath($records[0]['id_module'], 'variables.php');
|
||||
|
||||
if (sizeof($variables) > 0) {
|
||||
echo '
|
||||
|
@ -38,38 +38,33 @@ switch (post('op')) {
|
||||
$_SESSION['infos'][] = tr('Informazioni salvate correttamente!');
|
||||
|
||||
// Validazione indirizzo email mittente
|
||||
$check_email = Validate::isValidEmail($post['from_address'], 1, 0);
|
||||
$check_email = Validate::isValidEmail($post['from_address']);
|
||||
|
||||
// Se $check_email non è null e la riposta è negativa --> mostro il messaggio di avviso.
|
||||
if (!is_null($check_email)){
|
||||
if (!empty($check_email)) {
|
||||
$_SESSION['infos'][] = tr('Sintassi email verificata');
|
||||
|
||||
if ($check_email->format_valid) {
|
||||
$_SESSION['infos'][] = tr('Sintassi email verificata.');
|
||||
}
|
||||
else {
|
||||
$_SESSION['errors'][] = tr("Attenzione: l'indirizzo email _EMAIL_ sembra non essere valido", [
|
||||
'_EMAIL_' => $check_email->email,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($check_email->smtp) {
|
||||
if (is_object($check_email) && $check_email->smtp) {
|
||||
if ($check_email->smtp_check) {
|
||||
$_SESSION['infos'][] = tr('SMTP email verificato.');
|
||||
}
|
||||
elseif (!$check_email->smtp_check) {
|
||||
$_SESSION['warnings'][] = tr('SMTP email non verificato.');
|
||||
}
|
||||
else {
|
||||
$_SESSION['infos'][] = tr('SMTP email verificato');
|
||||
} elseif (!$check_email->smtp_check) {
|
||||
$_SESSION['warnings'][] = tr('SMTP email non verificato');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr("Attenzione: l'SMTP email _EMAIL_ sembra non essere valido", [
|
||||
'_EMAIL_' => $check_email->email,
|
||||
]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr("Attenzione: l'indirizzo email _EMAIL_ sembra non essere valido", [
|
||||
'_EMAIL_' => $check_email->email,
|
||||
]);
|
||||
|
||||
if (!empty($check_email->error->info)) {
|
||||
$_SESSION['errors'][] = $check_email->error->info;
|
||||
if (is_object($check_email) && !empty($check_email->error->info)) {
|
||||
$_SESSION['errors'][] = $check_email->error->info;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
|
@ -9,31 +9,22 @@ if (empty($info) || empty($info['enabled'])) {
|
||||
die(tr('Accesso negato'));
|
||||
}
|
||||
|
||||
// Inclusione di eventuale plugin personalizzato
|
||||
if (!empty($info['script'])) {
|
||||
// Inclusione di eventuale plugin personalizzato
|
||||
if (file_exists($docroot.'/modules/'.$info['module_dir'].'/plugins/custom/'.$info['script'])) {
|
||||
include $docroot.'/modules/'.$info['module_dir'].'/plugins/custom/'.$info['script'];
|
||||
} elseif (file_exists($docroot.'/modules/'.$info['module_dir'].'/plugins/'.$info['script'])) {
|
||||
include $docroot.'/modules/'.$info['module_dir'].'/plugins/'.$info['script'];
|
||||
}
|
||||
include App::filepath('modules/'.$info['module_dir'].'/plugins|custom|', $info['script']);
|
||||
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
|
||||
// Plugin standard
|
||||
else {
|
||||
// Caricamento helper plugin (verifico se ci sono helper personalizzati)
|
||||
if (file_exists($docroot.'/plugins/'.$info['directory'].'/custom/modutil.php')) {
|
||||
include_once $docroot.'/plugins/'.$info['directory'].'/custom/modutil.php';
|
||||
} elseif (file_exists($docroot.'/plugins/'.$info['directory'].'/modutil.php')) {
|
||||
include_once $docroot.'/plugins/'.$info['directory'].'/modutil.php';
|
||||
}
|
||||
include_once Plugins::filepath($info['id'], 'modutil.php');
|
||||
|
||||
// Lettura risultato query del plugin
|
||||
if (file_exists($docroot.'/plugins/'.$info['directory'].'/custom/init.php')) {
|
||||
include $docroot.'/plugins/'.$info['directory'].'/custom/init.php';
|
||||
} elseif (file_exists($docroot.'/plugins/'.$info['directory'].'/init.php')) {
|
||||
include $docroot.'/plugins/'.$info['directory'].'/init.php';
|
||||
}
|
||||
// Lettura risultato query del plugin
|
||||
include_once Plugins::filepath($info['id'], 'init.php');
|
||||
|
||||
// Esecuzione delle operazioni del plugin
|
||||
// Esecuzione delle operazioni del plugin
|
||||
include $docroot.'/actions.php';
|
||||
|
||||
if (empty($records)) {
|
||||
|
@ -399,6 +399,6 @@ class App
|
||||
$result = $original_file;
|
||||
}
|
||||
|
||||
return realpath($result);
|
||||
return slashes($result);
|
||||
}
|
||||
}
|
||||
|
12
src/Mail.php
12
src/Mail.php
@ -129,22 +129,12 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
|
||||
public static function getTemplateVariables($template, $id_record)
|
||||
{
|
||||
$template = self::getTemplate($template);
|
||||
$module = Modules::get($template['id_module']);
|
||||
|
||||
$file = DOCROOT.'/modules/'.$module['directory'].'|custom|/variables.php';
|
||||
|
||||
$original_file = str_replace('|custom|', '', $file);
|
||||
$custom_file = str_replace('|custom|', '/custom', $file);
|
||||
|
||||
$database = Database::getConnection();
|
||||
$dbo = $database;
|
||||
|
||||
// Lettura delle variabili nei singoli moduli
|
||||
if (file_exists($custom_file)) {
|
||||
$variables = require $custom_file;
|
||||
} elseif (file_exists($original_file)) {
|
||||
$variables = require $original_file;
|
||||
}
|
||||
$variables = include Modules::filepath($template['id_module'], 'variables.php');
|
||||
|
||||
return (array) $variables;
|
||||
}
|
||||
|
133
src/Prints.php
133
src/Prints.php
@ -108,6 +108,13 @@ class Prints
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera la stampa in PDF richiesta.
|
||||
*
|
||||
* @param string|int $print
|
||||
* @param int $id_record
|
||||
* @param string $filename
|
||||
*/
|
||||
public static function render($print, $id_record, $filename = null)
|
||||
{
|
||||
ob_end_clean();
|
||||
@ -145,6 +152,13 @@ class Prints
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un array associativo dalla codifica JSON delle opzioni di stampa.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function readOptions($string)
|
||||
{
|
||||
// Fix per contenuti con newline integrate
|
||||
@ -155,6 +169,13 @@ class Prints
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla se la stampa segue lo standard HTML2PDF.
|
||||
*
|
||||
* @param string|int $print
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isOldStandard($print)
|
||||
{
|
||||
$infos = self::get($print);
|
||||
@ -162,11 +183,26 @@ class Prints
|
||||
return file_exists($infos['full_directory'].'/pdfgen.'.$infos['directory'].'.php') || file_exists($infos['full_directory'].'/custom/pdfgen.'.$infos['directory'].'.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla se la stampa segue lo standard MPDF.
|
||||
*
|
||||
* @param string|int $print
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isNewStandard($print)
|
||||
{
|
||||
return !self::isOldStandard($print);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea la stampa secondo il formato deprecato HTML2PDF.
|
||||
*
|
||||
* @param string|int $id_print
|
||||
* @param int $id_record
|
||||
* @param string $filename
|
||||
* @param string $format
|
||||
*/
|
||||
protected static function oldLoader($id_print, $id_record, $filename = null, $format = 'A4')
|
||||
{
|
||||
$infos = self::get($id_print);
|
||||
@ -224,6 +260,13 @@ class Prints
|
||||
$html2pdf->output($filename, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Crea la stampa secondo il formato modulare MPDF.
|
||||
*
|
||||
* @param string|int $id_print
|
||||
* @param int $id_record
|
||||
* @param string $filename
|
||||
*/
|
||||
protected static function loader($id_print, $id_record, $filename = null)
|
||||
{
|
||||
$infos = self::get($id_print);
|
||||
@ -237,40 +280,23 @@ class Prints
|
||||
$user = Auth::user();
|
||||
|
||||
// Impostazioni di default
|
||||
if (file_exists(DOCROOT.'/templates/base/custom/settings.php')) {
|
||||
$default = include DOCROOT.'/templates/base/custom/settings.php';
|
||||
} else {
|
||||
$default = include DOCROOT.'/templates/base/settings.php';
|
||||
}
|
||||
$default = include App::filepath(DOCROOT.'/templates/base|custom|', 'settings.php');
|
||||
|
||||
// Impostazioni personalizzate della stampa
|
||||
$custom = [];
|
||||
if (file_exists($infos['full_directory'].'/custom/settings.php')) {
|
||||
$custom = include $infos['full_directory'].'/custom/settings.php';
|
||||
} elseif (file_exists($infos['full_directory'].'/settings.php')) {
|
||||
$custom = include $infos['full_directory'].'/settings.php';
|
||||
}
|
||||
$custom = include self::filepath($id_print, 'settings.php');
|
||||
|
||||
// Individuazione delle impostazioni finali
|
||||
$settings = array_merge($default, (array) $custom);
|
||||
|
||||
// Individuazione delle variabili fondamentali per la sostituzione dei contenuti
|
||||
if (file_exists($infos['full_directory'].'/custom/init.php')) {
|
||||
include $infos['full_directory'].'/custom/init.php';
|
||||
} elseif (file_exists($infos['full_directory'].'/init.php')) {
|
||||
include $infos['full_directory'].'/init.php';
|
||||
}
|
||||
include self::filepath($id_print, 'init.php');
|
||||
|
||||
// Individuazione delle variabili per la sostituzione
|
||||
include DOCROOT.'/templates/info.php';
|
||||
|
||||
// Generazione dei contenuti della stampa
|
||||
ob_start();
|
||||
if (file_exists($infos['full_directory'].'/custom/body.php')) {
|
||||
include $infos['full_directory'].'/custom/body.php';
|
||||
} else {
|
||||
include $infos['full_directory'].'/body.php';
|
||||
}
|
||||
include self::filepath($id_print, 'body.php');
|
||||
$report = ob_get_clean();
|
||||
|
||||
if (!empty($autofill)) {
|
||||
@ -293,20 +319,12 @@ class Prints
|
||||
|
||||
// Generazione dei contenuti dell'header
|
||||
ob_start();
|
||||
if (file_exists($infos['full_directory'].'/custom/header.php')) {
|
||||
include $infos['full_directory'].'/custom/header.php';
|
||||
} elseif (file_exists($infos['full_directory'].'/header.php')) {
|
||||
include $infos['full_directory'].'/header.php';
|
||||
}
|
||||
include self::filepath($id_print, 'header.php');
|
||||
$head = ob_get_clean();
|
||||
|
||||
// Generazione dei contenuti del footer
|
||||
ob_start();
|
||||
if (file_exists($infos['full_directory'].'/custom/footer.php')) {
|
||||
include $infos['full_directory'].'/custom/footer.php';
|
||||
} elseif (file_exists($infos['full_directory'].'/footer.php')) {
|
||||
include $infos['full_directory'].'/footer.php';
|
||||
}
|
||||
include self::filepath($id_print, 'footer.php');
|
||||
$foot = ob_get_clean();
|
||||
|
||||
// Header di default
|
||||
@ -328,14 +346,11 @@ class Prints
|
||||
'templates/base/style.css',
|
||||
];
|
||||
|
||||
$settings['orientation'] = strtoupper($settings['orientation']) == 'L' ? 'L' : 'P';
|
||||
$settings['format'] = is_string($settings['format']) ? $settings['format'].($settings['orientation'] == 'L' ? '-L' : '') : $settings['format'];
|
||||
|
||||
// Instanziamento dell'oggetto mPDF
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8',
|
||||
'format' => $settings['format'],
|
||||
'orientation' => $settings['orientation'],
|
||||
'orientation' => strtoupper($settings['orientation']) == 'L' ? 'L' : 'P',
|
||||
'font-size' => $settings['font-size'],
|
||||
'margin_left' => $settings['margins']['left'],
|
||||
'margin_right' => $settings['margins']['right'],
|
||||
@ -371,6 +386,15 @@ class Prints
|
||||
$mpdf->Output($filename, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Individua il link per la stampa.
|
||||
*
|
||||
* @param string|int $print
|
||||
* @param int $id_record
|
||||
* @param string $get
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getHref($print, $id_record, $get = '')
|
||||
{
|
||||
$infos = self::get($print);
|
||||
@ -396,15 +420,54 @@ class Prints
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il codice semplificato per il link alla stampa.
|
||||
*
|
||||
* @deprecated 2.4.1
|
||||
*
|
||||
* @param string|int $print
|
||||
* @param int $id_record
|
||||
* @param string $btn
|
||||
* @param string $title
|
||||
* @param string $icon
|
||||
* @param string $get
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getLink($print, $id_record, $btn = null, $title = null, $icon = null, $get = '')
|
||||
{
|
||||
return '{( "name": "button", "type": "print", "id": "'.$print.'", "id_record": "'.$id_record.'", "label": "'.$title.'", "icon": "'.$icon.'", "parameters": "'.$get.'", "class": "'.$btn.'" )}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce il link per la visualizzazione del PDF.
|
||||
*
|
||||
* @param string|int $print
|
||||
* @param int $id_record
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getPreviewLink($print, $id_record, $filename)
|
||||
{
|
||||
self::render($print, $id_record, $filename);
|
||||
|
||||
return ROOTDIR.'/assets/dist/pdfjs/web/viewer.html?file=../../../../'.ltrim(str_replace(DOCROOT, '', $filename), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Individua il percorso per il file.
|
||||
*
|
||||
* @param string|int $template
|
||||
* @param string $file
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function filepath($template, $file)
|
||||
{
|
||||
$template = self::get($template);
|
||||
$directory = 'templates/'.$template['directory'].'|custom|';
|
||||
|
||||
return App::filepath($directory, $file);
|
||||
}
|
||||
}
|
||||
|
111
src/Validate.php
111
src/Validate.php
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Mpociot\VatCalculator\VatCalculator;
|
||||
use Respect\Validation\Validator as v;
|
||||
|
||||
/**
|
||||
* Classe per la gestione delle funzioni VALIDATE richiamabili del progetto.
|
||||
*
|
||||
@ -12,15 +15,28 @@ class Validate
|
||||
*
|
||||
* @param string $vat_number
|
||||
*
|
||||
* @return object
|
||||
* @return bool|null
|
||||
*/
|
||||
public static function isValidVatNumber($vat_number)
|
||||
{
|
||||
$access_key = Settings::get('apilayer API key for VAT number');
|
||||
$vat_number = starts_with($vat_number, 'IT') ? $vat_number : 'IT'.$vat_number;
|
||||
|
||||
if ((!empty($vat_number)) && (!empty($access_key))) {
|
||||
if (strpos($vat_number, 'IT') === false) {
|
||||
$vat_number = 'IT'.$vat_number;
|
||||
try {
|
||||
$validator = new VatCalculator();
|
||||
|
||||
if (!$validator->isValidVATNumber($vat_number)) {
|
||||
return false;
|
||||
}
|
||||
} catch (VATCheckUnavailableException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$access_key = Settings::get('apilayer API key for VAT number');
|
||||
if (!empty($access_key)) {
|
||||
if (!function_exists('curl_init')) {
|
||||
$_SESSION['warnings'][] = tr('Estensione cURL non installata');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
@ -40,94 +56,79 @@ class Validate
|
||||
$data->valid = 0;
|
||||
}
|
||||
|
||||
//$data->url = $url;
|
||||
//$data->json_last_error = json_last_error();
|
||||
//$data->json_last_error_msg = json_last_error_msg();
|
||||
return $data->valid;
|
||||
}
|
||||
|
||||
return $data;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controlla se l'email inserita è valida.
|
||||
*
|
||||
* @param string $email
|
||||
* @param bool $format
|
||||
* @param bool $smtp
|
||||
*
|
||||
* @return object
|
||||
* @return bool|object
|
||||
*/
|
||||
public static function isValidEmail($email, $format = 1, $smtp = 0)
|
||||
public static function isValidEmail($email, $smtp = 0)
|
||||
{
|
||||
if (!v::email()->validate($email)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$access_key = Settings::get('apilayer API key for Email');
|
||||
if (!empty($access_key)) {
|
||||
if (!function_exists('curl_init')) {
|
||||
$_SESSION['warnings'][] = tr('Estensione cURL non installata');
|
||||
|
||||
/*$data = (object) [
|
||||
'format_valid' => NULL,
|
||||
'mx_found' => NULL,
|
||||
'smtp_check' => NULL,
|
||||
];*/
|
||||
|
||||
if ((!empty($email)) && (!empty($access_key))) {
|
||||
|
||||
if(!function_exists("curl_init")) die("cURL extension is not installed");
|
||||
return true;
|
||||
}
|
||||
|
||||
$qs = '&email='.urlencode($email);
|
||||
$qs .= "&smtp=$smtp";
|
||||
$qs .= "&format=$format";
|
||||
$qs .= "&resource=check_email";
|
||||
$qs .= '&format=1';
|
||||
$qs .= '&resource=check_email';
|
||||
|
||||
$url = "https://services.osmcloud.it/api/?token=$access_key".$qs;
|
||||
|
||||
$curl_options = array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_HEADER => 0,
|
||||
CURLOPT_RETURNTRANSFER => TRUE,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_SSL_VERIFYPEER => 0,
|
||||
CURLOPT_FOLLOWLOCATION => TRUE,
|
||||
CURLOPT_ENCODING => 'gzip,deflate',
|
||||
);
|
||||
|
||||
$curl_options = [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_HEADER => 0,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_SSL_VERIFYPEER => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_ENCODING => 'gzip,deflate',
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array( $ch, $curl_options );
|
||||
$output = curl_exec( $ch );
|
||||
curl_setopt_array($ch, $curl_options);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$data = json_decode($output,false);
|
||||
|
||||
//var_dump ($data);
|
||||
//echo "format_valid: ".$data->format_valid;
|
||||
//echo $url;
|
||||
//exit;
|
||||
$data = json_decode($output, false);
|
||||
|
||||
/*se la riposta è null verficando il formato, il record mx o il server smtp imposto la relativa proprietà dell'oggetto a 0*/
|
||||
if (($data->format_valid == null) && ($format)) {
|
||||
if ($data->format_valid == null) {
|
||||
$data->format_valid = 0;
|
||||
}
|
||||
|
||||
if (($data->mx_found == null) && ($smtp)) {
|
||||
if ($data->mx_found == null && $smtp) {
|
||||
$data->mx_found = 0;
|
||||
}
|
||||
|
||||
if (($data->smtp_check == null) && ($smtp)) {
|
||||
if ($data->smtp_check == null && $smtp) {
|
||||
$data->smtp_check = 0;
|
||||
}
|
||||
|
||||
/*controllo o meno smtp
|
||||
if ($data->smtp_check==false)
|
||||
$data->smtp_check = 0;
|
||||
|
||||
if ($data->mx_found==false)
|
||||
$data->mx_found = 0;
|
||||
*/
|
||||
/* --- */
|
||||
$data->smtp = $smtp;
|
||||
|
||||
|
||||
$data->json_last_error = json_last_error();
|
||||
$data->json_last_error_msg = json_last_error_msg();
|
||||
|
||||
return empty($data->format_valid) ? false : $data;
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user