mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-01-10 22:53:52 +01:00
Miglioramenti minori per account email
This commit is contained in:
parent
c1f89f437c
commit
e78323a7a5
@ -2,8 +2,10 @@
|
||||
|
||||
namespace Modules\Emails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Common\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Notifications\EmailNotification;
|
||||
use Traits\StoreTrait;
|
||||
|
||||
class Account extends Model
|
||||
@ -13,6 +15,26 @@ class Account extends Model
|
||||
|
||||
protected $table = 'em_accounts';
|
||||
|
||||
public function testConnection()
|
||||
{
|
||||
// Impostazione di connected_at a NULL
|
||||
$this->connected_at = null;
|
||||
$this->save();
|
||||
|
||||
// Creazione email di test
|
||||
$mail = new EmailNotification($this->id);
|
||||
// Tentativo di connessione
|
||||
$result = $mail->testSMTP();
|
||||
|
||||
// Salvataggio della data di connessione per test riuscito
|
||||
if ($result) {
|
||||
$this->connected_at = Carbon::now();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/* Relazioni Eloquent */
|
||||
|
||||
public function templates()
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use Notifications\EmailNotification;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
switch (post('op')) {
|
||||
@ -68,16 +66,16 @@ switch (post('op')) {
|
||||
break;
|
||||
|
||||
case 'test':
|
||||
$mail = new EmailNotification($id_record);
|
||||
$result = $account->testConnection();
|
||||
|
||||
echo json_encode([
|
||||
'test' => $mail->testSMTP(),
|
||||
'test' => $result,
|
||||
]);
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$dbo->query('UPDATE em_accounts SET deleted_at = NOW() WHERE id='.prepare($id_record));
|
||||
$account->delete();
|
||||
|
||||
flash()->info(tr('Account email eliminato!'));
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Modules\Emails\Account;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (isset($id_record)) {
|
||||
$account = Account::find($id_record);
|
||||
|
||||
$record = $dbo->fetchOne('SELECT * FROM em_accounts WHERE id='.prepare($id_record).' AND deleted_at IS NULL');
|
||||
}
|
||||
|
@ -115,3 +115,7 @@ ALTER TABLE `co_preventivi` ADD COLUMN `tipo_validita` ENUM('days', 'months', 'y
|
||||
-- Aggiunta campi Peso e Volume in DDT e Fatture accompagnatorie
|
||||
ALTER TABLE `dt_ddt` ADD COLUMN `peso` decimal(12, 4) AFTER `n_colli`, ADD COLUMN `volume` decimal(12, 4) AFTER `peso`;
|
||||
ALTER TABLE `co_documenti` ADD COLUMN `peso` decimal(12, 4) AFTER `n_colli`, ADD COLUMN `volume` decimal(12, 4) AFTER `peso`;
|
||||
|
||||
-- Aggiunta data di connessione agli account SMTP
|
||||
ALTER TABLE `em_accounts` ADD `connected_at` TIMESTAMP NULL DEFAULT NULL AFTER `timeout`;
|
||||
UPDATE `em_accounts` SET `connected_at` = NOW();
|
||||
|
Loading…
Reference in New Issue
Block a user