Correzioni di sincronizzazione API
This commit is contained in:
parent
74b32dc697
commit
eb427f8895
5
mail.php
5
mail.php
|
@ -8,9 +8,6 @@ $template = Template::find(get('id'));
|
|||
$module = $template->module;
|
||||
$smtp = $template->account;
|
||||
|
||||
$body = $template['body'];
|
||||
$subject = $template['subject'];
|
||||
|
||||
$body = $module->replacePlaceholders($id_record, $template['body']);
|
||||
$subject = $module->replacePlaceholders($id_record, $template['subject']);
|
||||
|
||||
|
@ -45,7 +42,7 @@ echo '
|
|||
<form action="" method="post" id="email-form">
|
||||
<input type="hidden" name="op" value="send-email">
|
||||
<input type="hidden" name="backto" value="'.(get('back') ? get('back') : 'record-edit').'">
|
||||
|
||||
|
||||
<input type="hidden" name="id_module" value="'.$id_module.'">
|
||||
<input type="hidden" name="id_record" value="'.$id_record.'">
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use API\Resource;
|
|||
use Modules;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
|
||||
class Impianti extends Resource implements RetrieveInterface
|
||||
class Impianti extends Resource implements RetrieveInterface, CreateInterface
|
||||
{
|
||||
public function retrieve($request)
|
||||
{
|
||||
|
@ -25,4 +25,23 @@ class Impianti extends Resource implements RetrieveInterface
|
|||
'parameters' => $parameters,
|
||||
];
|
||||
}
|
||||
|
||||
public function create($request)
|
||||
{
|
||||
$data = $request['data'];
|
||||
$id_record = $data['id_intervento'];
|
||||
|
||||
$database = database();
|
||||
$database->query('DELETE FROM my_impianti_interventi WHERE `idintervento` = :id_intervento', [
|
||||
':id_intervento' => $id_record,
|
||||
]);
|
||||
|
||||
$impianti = $data['impianti'];
|
||||
foreach ($impianti as $impianto) {
|
||||
$database->insert('my_impianti_interventi', [
|
||||
'idintervento' => $id_record,
|
||||
'idimpianto' => $impianto,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use API\Resource;
|
|||
use Modules;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Emails\Template;
|
||||
use Modules\Emails\Mail;
|
||||
|
||||
class Rapportino extends Resource implements RetrieveInterface, CreateInterface
|
||||
{
|
||||
|
@ -21,9 +22,6 @@ class Rapportino extends Resource implements RetrieveInterface, CreateInterface
|
|||
$template = Template::where('name', 'Rapportino intervento')->first();
|
||||
$module = $template->module;
|
||||
|
||||
$body = $template['body'];
|
||||
$subject = $template['subject'];
|
||||
|
||||
$body = $module->replacePlaceholders($id_record, $template['body']);
|
||||
$subject = $module->replacePlaceholders($id_record, $template['subject']);
|
||||
$email = $module->replacePlaceholders($id_record, '{email}');
|
||||
|
@ -40,6 +38,34 @@ class Rapportino extends Resource implements RetrieveInterface, CreateInterface
|
|||
|
||||
public function create($request)
|
||||
{
|
||||
// TODO: Implement create() method.
|
||||
$id_record = $request['id_intervento'];
|
||||
|
||||
$template = Template::where('name', 'Rapportino intervento')->first();
|
||||
$mail = Mail::build($this->getUser(), $template, $id_record);
|
||||
|
||||
// Rimozione allegati predefiniti
|
||||
$mail->resetPrints();
|
||||
|
||||
// Destinatari
|
||||
$receivers = $request['receivers'];
|
||||
foreach ($receivers as $receiver) {
|
||||
$mail->addReceiver($receiver['email'], $receiver['tipo']);
|
||||
}
|
||||
|
||||
// Contenuti
|
||||
$mail->subject = $request['subject'];
|
||||
$mail->content = $request['body'];
|
||||
|
||||
// Stampe da allegare
|
||||
$prints = $request['prints'];
|
||||
foreach ($prints as $print) {
|
||||
$mail->addPrint($print['id']);
|
||||
}
|
||||
|
||||
$mail->save();
|
||||
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -485,5 +485,6 @@ UPDATE `zz_views` SET `query` = 'qta', `format` = 1 WHERE `id_module` = (SELECT
|
|||
INSERT INTO `zz_api_resources` (`id`, `version`, `type`, `resource`, `class`, `enabled`) VALUES
|
||||
(NULL, 'v1', 'retrieve', 'impianti', 'Modules\\Impianti\\API\\v1\\Impianti', '1'),
|
||||
(NULL, 'v1', 'retrieve', 'impianti_intervento', 'Modules\\Interventi\\API\\v1\\Impianti', '1'),
|
||||
(NULL, 'v1', 'create', 'impianti_intervento', 'Modules\\Interventi\\API\\v1\\Impianti', '1'),
|
||||
(NULL, 'v1', 'retrieve', 'rapportino', 'Modules\\Interventi\\API\\v1\\Rapportino', '1'),
|
||||
(NULL, 'v1', 'create', 'rapportino', 'Modules\\Interventi\\API\\v1\\Rapportino', '1');
|
||||
|
|
Loading…
Reference in New Issue