diff --git a/index.php b/index.php index 1c7e400..6fac5fc 100644 --- a/index.php +++ b/index.php @@ -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)); diff --git a/tpl/json/connection.html b/tpl/json/connection.html deleted file mode 100644 index e1ee7d6..0000000 --- a/tpl/json/connection.html +++ /dev/null @@ -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} diff --git a/tpl/json/edit_users.html b/tpl/json/edit_users.html deleted file mode 100644 index 0ef113f..0000000 --- a/tpl/json/edit_users.html +++ /dev/null @@ -1,9 +0,0 @@ -{if condition="$error != ''"} -

{$error}

-{/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} diff --git a/tpl/json/index.html b/tpl/json/index.html index 8f435f9..296a98b 100644 --- a/tpl/json/index.html +++ b/tpl/json/index.html @@ -6,7 +6,7 @@ TODO ***

Balance

Read line owes case {$currency} to column. You can click on links to confirm the payback. - +
{loop="users"} diff --git a/tpl/json/new_invoice.html b/tpl/json/new_invoice.html deleted file mode 100644 index c9f38a6..0000000 --- a/tpl/json/new_invoice.html +++ /dev/null @@ -1 +0,0 @@ -{if condition="LANG == 'en'}Nothing to show.{else}Il n'y a rien à afficher.{/if} diff --git a/tpl/json/settings.html b/tpl/json/settings.html deleted file mode 100644 index 314e898..0000000 --- a/tpl/json/settings.html +++ /dev/null @@ -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}
Owes\To