Remove useless files in JSON tpl + start notifications

This commit is contained in:
Phyks 2014-08-31 18:32:31 +02:00
parent 09bbb789c6
commit 7456210772
6 changed files with 28 additions and 27 deletions

View File

@ -471,6 +471,9 @@
case 'new_invoice':
case 'edit_invoice':
$users_list = new User();
$users_list = $users_list->load();
if(!empty($_GET['id'])) {
$invoice = new Invoice();
$invoice = $invoice->load(array('id'=>(int) $_GET['id']), true);
@ -508,14 +511,16 @@
else {
$invoice = new Invoice();
if(!empty($_POST['id']))
if(!empty($_POST['id'])) {
$invoice->setId($_POST['id']);
}
$invoice->setWhat($_POST['what']);
$invoice->setAmount($_POST['amount']);
if(empty($_POST['id']))
if(empty($_POST['id'])) {
$invoice->setBuyer($current_user->getId());
}
$invoice->setDate(0, int2ampm($_POST['date_hour']), $_POST['date_day'], $_POST['date_month'], $_POST['date_year']);
@ -524,6 +529,26 @@
$invoice->save();
// Send notifications
if (!empty($_POST['id'])) {
$invoice = new Invoice();
$invoice = $invoice->load(array('id'=>$_POST['id']), true);
$buyer = $invoice->getBuyer();
}
else {
$buyer = $current_user->getId();
}
foreach ($users_in as $user_in=>$guest) {
if (empty($_POST['id']) && $user_in == $buyer) {
continue;
}
$user_in_details = new User();
$user_in_details = $user_in_details->load(array('id'=>$user_in), true);
if (!empty($user_in_details->getEmail()) && $user_in_details->getNotifications() === 3) {
sendmail($user_in_details, $subject, $msg, $from); // TODO notifs
}
}
// Clear the cache
($cached_files = glob(raintpl::$cache_dir."*.rtpl.php")) or ($cached_files = array());
array_map("unlink", $cached_files);
@ -538,9 +563,6 @@
}
}
$users_list = new User();
$users_list = $users_list->load();
$tpl->assign('days', range(1,31));
$tpl->assign('months', range(1, 12));
$tpl->assign('years', range(date('Y') - 1, date('Y') + 1));

View File

@ -1,5 +0,0 @@
{if condition="LANG=='fr'"}
Vous devez utiliser votre token unique d'identification pour l'utilisation de l'API JSON. Vous pouvez le trouver dans le menu "Modifier votre mot de passe".
{else}
You must use your unique id token to use JSON API. You can find it under the "Edit password" menu.
{/if}

View File

@ -1,9 +0,0 @@
{if condition="$error != ''"}
<p class="error">{$error}</p>
{/if}
{if condition="$view == 'list_users'"}
{function="json_encode(array_map(function($obj) { return $obj->sessionStore(false);}, $users))"}
{else}
{if condition="LANG == 'en'"}Nothing to show.{else}Il n'y a rien à afficher.{/if}
{/if}

View File

@ -1 +0,0 @@
{if condition="LANG == 'en'}Nothing to show.{else}Il n'y a rien à afficher.{/if}

View File

@ -1,6 +0,0 @@
{if condition="!$show_settings"}
{"notice":{function="json_encode($notice)"}}
{else}
{"mysql_host":{function="json_encode($mysql_host)"}, "mysql_login":{function="json_encode($mysql_login)"}, "mysql_db":{function="json_encode($mysql_db)"}, "mysql_prefix":{function="json_encode($mysql_prefix)"}, "instance_title":{function="json_encode($instance_title)"}, "base_url":{function="json_encode($base_url)"}, "currency":{function="json_encode($currency)"}, "timezone":{function="json_encode($timezone)"}, "templates":{function="json_encode(TwoDArrayToOneD($templates, 'value'))"}, "current_template":{function="json_encode($current_template)"}", "email_webmaster":{function="json_encode($email_webmaster)"}}
{/if}