mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Working on API
This commit is contained in:
parent
67046b39de
commit
bb560778af
@ -4,6 +4,6 @@ return array(
|
||||
|
||||
//'TAG_MANAGER_KEY' => '',
|
||||
//'ANALYTICS_KEY' => '',
|
||||
//'NINJA_DEV' => true,
|
||||
'NINJA_DEV' => true,
|
||||
|
||||
);
|
||||
|
@ -67,7 +67,7 @@ class AccountController extends \BaseController {
|
||||
|
||||
public function setTrashVisible($entityType, $visible)
|
||||
{
|
||||
Session::put('show_trash', $visible == 'true');
|
||||
Session::put("show_trash:{$entityType}", $visible == 'true');
|
||||
return Redirect::to("{$entityType}s");
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class ClientApiController extends Controller {
|
||||
public function index()
|
||||
{
|
||||
if (!Utils::isPro()) {
|
||||
Redirect::to('/');
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
$clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get();
|
||||
@ -35,14 +35,24 @@ class ClientApiController extends Controller {
|
||||
public function store()
|
||||
{
|
||||
if (!Utils::isPro()) {
|
||||
Redirect::to('/');
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
$data = Input::all();
|
||||
$client = $this->clientRepo->save(false, $data, false);
|
||||
$error = $this->clientRepo->getErrors($data);
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$headers = Utils::getApiHeaders();
|
||||
return Response::make($error, 500, $headers);
|
||||
}
|
||||
else
|
||||
{
|
||||
$client = $this->clientRepo->save(false, $data, false);
|
||||
$response = json_encode($client, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
return Response::make($response, 200, $headers);
|
||||
}
|
||||
|
||||
$response = json_encode($client, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
return Response::make($response, 200, $headers);
|
||||
}
|
||||
}
|
@ -111,6 +111,11 @@ class HomeController extends BaseController {
|
||||
return View::make('secure_payment');
|
||||
}
|
||||
|
||||
public function showCompare()
|
||||
{
|
||||
return View::make('public.compare');
|
||||
}
|
||||
|
||||
public function invoiceNow()
|
||||
{
|
||||
if (Auth::check())
|
||||
|
@ -15,7 +15,7 @@ class InvoiceApiController extends Controller {
|
||||
public function index()
|
||||
{
|
||||
if (!Utils::isPro()) {
|
||||
Redirect::to('/');
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
$invoices = Invoice::scope()->where('invoices.is_quote', '=', false)->orderBy('created_at', 'desc')->get();
|
||||
|
@ -15,7 +15,7 @@ class PaymentApiController extends Controller {
|
||||
public function index()
|
||||
{
|
||||
if (!Utils::isPro()) {
|
||||
Redirect::to('/');
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
$payments = Payment::scope()->orderBy('created_at', 'desc')->get();
|
||||
|
@ -15,7 +15,7 @@ class QuoteApiController extends Controller {
|
||||
public function index()
|
||||
{
|
||||
if (!Utils::isPro()) {
|
||||
Redirect::to('/');
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
$invoices = Invoice::scope()->where('invoices.is_quote', '=', true)->orderBy('created_at', 'desc')->get();
|
||||
|
@ -441,6 +441,10 @@ class Activity extends Eloquent
|
||||
|
||||
private static function checkSubscriptions($event, $data)
|
||||
{
|
||||
if (!Auth::check()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$subscription = Auth::user()->account->getSubscription($event);
|
||||
|
||||
if ($subscription)
|
||||
|
@ -13,7 +13,7 @@ class ClientRepository
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->select('clients.public_id','clients.name','contacts.first_name','contacts.last_name','clients.balance','clients.last_login','clients.created_at','clients.work_phone','contacts.email','clients.currency_id');
|
||||
|
||||
if (!\Session::get('show_trash'))
|
||||
if (!\Session::get('show_trash:client'))
|
||||
{
|
||||
$query->where('clients.deleted_at', '=', null);
|
||||
}
|
||||
@ -32,15 +32,19 @@ class ClientRepository
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function save($publicId, $data, $notify = true)
|
||||
public function getErrors($data)
|
||||
{
|
||||
$contact = isset($data['contacts']) ? (array)$data['contacts'][0] : (isset($data['contact']) ? $data['contact'] : []);
|
||||
$validator = \Validator::make($contact, ['email' => 'required|email']);
|
||||
if ($validator->fails()) {
|
||||
dd($validator->messages());
|
||||
return false;
|
||||
return $validator->messages();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save($publicId, $data, $notify = true)
|
||||
{
|
||||
if (!$publicId || $publicId == "-1")
|
||||
{
|
||||
$client = Client::createNew();
|
||||
|
@ -22,7 +22,7 @@ class CreditRepository
|
||||
$query->where('clients.public_id', '=', $clientPublicId);
|
||||
}
|
||||
|
||||
if (!\Session::get('show_trash'))
|
||||
if (!\Session::get('show_trash:credit'))
|
||||
{
|
||||
$query->where('credits.deleted_at', '=', null);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class InvoiceRepository
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->select('clients.public_id as client_public_id', 'invoice_number', 'clients.name as client_name', 'invoices.public_id', 'amount', 'invoices.balance', 'invoice_date', 'due_date', 'invoice_statuses.name as invoice_status_name', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'quote_id', 'quote_invoice_id');
|
||||
|
||||
if (!\Session::get('show_trash'))
|
||||
if (!\Session::get('show_trash:invoice'))
|
||||
{
|
||||
$query->where('invoices.deleted_at', '=', null);
|
||||
}
|
||||
@ -65,8 +65,8 @@ class InvoiceRepository
|
||||
{
|
||||
$query->where('clients.public_id', '=', $clientPublicId);
|
||||
}
|
||||
|
||||
if (!\Session::get('show_trash'))
|
||||
|
||||
if (!\Session::get('show_trash:invoice'))
|
||||
{
|
||||
$query->where('invoices.deleted_at', '=', null);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class PaymentRepository
|
||||
->where('contacts.is_primary', '=', true)
|
||||
->select('payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'payment_types.name as payment_type', 'payments.account_gateway_id');
|
||||
|
||||
if (!\Session::get('show_trash'))
|
||||
if (!\Session::get('show_trash:payment'))
|
||||
{
|
||||
$query->where('payments.deleted_at', '=', null);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
@ -34,6 +33,7 @@ Route::post('/contact_submit', 'HomeController@doContactUs');
|
||||
Route::get('/faq', 'HomeController@showFaq');
|
||||
Route::get('/features', 'HomeController@showFeatures');
|
||||
Route::get('/testimonials', 'HomeController@showTestimonials');
|
||||
Route::get('/compare-online-invoicing-sites', 'HomeController@showCompare');
|
||||
|
||||
Route::get('log_error', 'HomeController@logError');
|
||||
Route::get('invoice_now', 'HomeController@invoiceNow');
|
||||
@ -133,10 +133,6 @@ Route::group(array('prefix' => 'api/v1', 'before' => 'auth.basic'), function()
|
||||
Route::resource('invoices', 'InvoiceApiController');
|
||||
Route::resource('quotes', 'QuoteApiController');
|
||||
Route::resource('payments', 'PaymentApiController');
|
||||
});
|
||||
|
||||
Route::group(array('before' => 'auth.basic'), function()
|
||||
{
|
||||
Route::post('api/hooks', 'IntegrationController@subscribe');
|
||||
});
|
||||
|
||||
|
@ -725,24 +725,30 @@
|
||||
function onEmailClick() {
|
||||
@if (Auth::user()->confirmed)
|
||||
if (confirm('Are you sure you want to email this {{ $entityType }}?')) {
|
||||
$('#action').val('email');
|
||||
$('#submitButton').click();
|
||||
submitAction('email');
|
||||
}
|
||||
@else
|
||||
$('#action').val('email');
|
||||
$('#submitButton').click();
|
||||
submitAction('email');
|
||||
@endif
|
||||
}
|
||||
|
||||
function onSaveClick() {
|
||||
$('#action').val('');
|
||||
$('#submitButton').click();
|
||||
submitAction('');
|
||||
}
|
||||
|
||||
function submitAction(value) {
|
||||
if (!isSaveValid()) {
|
||||
model.showClientForm();
|
||||
return;
|
||||
}
|
||||
$('#action').val(value);
|
||||
$('#submitButton').click();
|
||||
}
|
||||
|
||||
function isSaveValid() {
|
||||
var isValid = false;
|
||||
for (var i=0; i<self.invoice().client().contacts().length; i++) {
|
||||
var contact = self.invoice().client().contacts()[i];
|
||||
for (var i=0; i<model.invoice().client().contacts().length; i++) {
|
||||
var contact = model.invoice().client().contacts()[i];
|
||||
if (isValidEmailAddress(contact.email())) {
|
||||
isValid = true;
|
||||
} else {
|
||||
@ -773,13 +779,11 @@
|
||||
}
|
||||
|
||||
function onCloneClick() {
|
||||
$('#action').val('clone');
|
||||
$('#submitButton').click();
|
||||
submitAction('clone');
|
||||
}
|
||||
|
||||
function onConvertClick() {
|
||||
$('#action').val('convert');
|
||||
$('#submitButton').click();
|
||||
submitAction('convert');
|
||||
}
|
||||
|
||||
@if ($client && $invoice)
|
||||
@ -793,14 +797,12 @@
|
||||
@endif
|
||||
|
||||
function onArchiveClick() {
|
||||
$('#action').val('archive');
|
||||
$('#submitButton').click();
|
||||
submitAction('archive');
|
||||
}
|
||||
|
||||
function onDeleteClick() {
|
||||
if (confirm('Are you sure you want to delete this {{ $entityType }}?')) {
|
||||
$('#action').val('delete');
|
||||
$('#submitButton').click();
|
||||
submitAction('delete');
|
||||
}
|
||||
}
|
||||
|
||||
@ -811,8 +813,7 @@
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
$('#action').val('');
|
||||
$('#submitButton').click();
|
||||
submitAction('');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1099,8 +1100,6 @@
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, self.mapping, self);
|
||||
self.is_recurring(parseInt(data.is_recurring));
|
||||
self.is_recurring(parseInt(data.is_recurring) == 1);
|
||||
self.is_recurring(parseInt(data.is_recurring) == 1);
|
||||
} else {
|
||||
self.addItem();
|
||||
}
|
||||
@ -1590,10 +1589,12 @@
|
||||
}
|
||||
var invitationContactIds = {{ json_encode($invitationContactIds) }};
|
||||
var client = clientMap[invoice.client.public_id];
|
||||
for (var i=0; i<client.contacts.length; i++) {
|
||||
var contact = client.contacts[i];
|
||||
contact.send_invoice = invitationContactIds.indexOf(contact.public_id) >= 0;
|
||||
}
|
||||
if (client) { // in case it's deleted
|
||||
for (var i=0; i<client.contacts.length; i++) {
|
||||
var contact = client.contacts[i];
|
||||
contact.send_invoice = invitationContactIds.indexOf(contact.public_id) >= 0;
|
||||
}
|
||||
}
|
||||
model.invoice().addItem();
|
||||
//model.addTaxRate();
|
||||
@else
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<label for="trashed" style="font-weight:normal; margin-left: 10px;">
|
||||
<input id="trashed" type="checkbox" onclick="setTrashVisible()"
|
||||
{{ Session::get('show_trash') ? 'checked' : ''}}/> {{ trans('texts.show_archived_deleted')}} {{ strtolower(trans('texts.'.$entityType.'s')) }}
|
||||
{{ Session::get("show_trash:{$entityType}") ? 'checked' : ''}}/> {{ trans('texts.show_archived_deleted')}} {{ strtolower(trans('texts.'.$entityType.'s')) }}
|
||||
</label>
|
||||
|
||||
<div id="top_right_buttons" class="pull-right">
|
||||
|
@ -45,6 +45,8 @@
|
||||
.hero-testi {
|
||||
background-image: url({{ asset('/images/hero-bg-testi.jpg') }});
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
@stop
|
||||
|
@ -47488,7 +47488,7 @@ function displayInvoiceHeader(doc, invoice, layout) {
|
||||
doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item);
|
||||
doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description);
|
||||
doc.text(costX, layout.tableTop, invoiceLabels.unit_cost);
|
||||
if (invoice.account.hide_quantity === '0') {
|
||||
if (invoice.account.hide_quantity != '1') {
|
||||
doc.text(qtyX, layout.tableTop, invoiceLabels.quantity);
|
||||
}
|
||||
doc.text(totalX, layout.tableTop, invoiceLabels.line_total);
|
||||
@ -47507,7 +47507,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
var shownItem = false;
|
||||
var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
|
||||
var tableTop = layout.tableTop;
|
||||
var hideQuantity = invoice.account.hide_quantity === '1';
|
||||
var hideQuantity = invoice.account.hide_quantity == '1';
|
||||
|
||||
doc.setFontSize(8);
|
||||
for (var i=0; i<invoice.invoice_items.length; i++) {
|
||||
@ -47561,7 +47561,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
if (lineTotal) {
|
||||
total += lineTotal;
|
||||
}
|
||||
lineTotal = formatMoney(lineTotal, currencyId, true);
|
||||
lineTotal = formatMoney(lineTotal, currencyId);
|
||||
|
||||
var costX = layout.unitCostRight - (doc.getStringUnitWidth(cost) * doc.internal.getFontSize());
|
||||
var qtyX = layout.qtyRight - (doc.getStringUnitWidth(qty) * doc.internal.getFontSize());
|
||||
|
@ -1293,15 +1293,19 @@ div.fb_iframe_widget > span {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.compare-table .glyphicon,
|
||||
.plans-table .glyphicon {
|
||||
color: #fff;
|
||||
border-radius: 50px;
|
||||
padding: 5px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.compare-table .glyphicon-remove,
|
||||
.plans-table .glyphicon-remove {
|
||||
background-color: #da4830;
|
||||
}
|
||||
.compare-table .glyphicon-ok,
|
||||
.plans-table .glyphicon-ok {
|
||||
background-color: #35c156;
|
||||
}
|
||||
@ -1350,6 +1354,28 @@ div.fb_iframe_widget > span {
|
||||
background: #1e84a5;
|
||||
}
|
||||
|
||||
|
||||
table.compare-table td {
|
||||
height: 70px;
|
||||
vertical-align: middle !important;
|
||||
}
|
||||
table.compare-table th {
|
||||
height: 70px;
|
||||
vertical-align: middle !important;
|
||||
text-align: center;
|
||||
color: white;
|
||||
}
|
||||
table.compare-table td:first-child {
|
||||
text-align: left;
|
||||
}
|
||||
table.compare-table-free th {
|
||||
background-color: #0b4d78;
|
||||
}
|
||||
table.compare-table-paid th {
|
||||
background-color: #e37329;
|
||||
}
|
||||
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.hide-desktop {display: none !important;}
|
||||
}
|
||||
|
@ -1275,15 +1275,19 @@ div.fb_iframe_widget > span {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.compare-table .glyphicon,
|
||||
.plans-table .glyphicon {
|
||||
color: #fff;
|
||||
border-radius: 50px;
|
||||
padding: 5px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.compare-table .glyphicon-remove,
|
||||
.plans-table .glyphicon-remove {
|
||||
background-color: #da4830;
|
||||
}
|
||||
.compare-table .glyphicon-ok,
|
||||
.plans-table .glyphicon-ok {
|
||||
background-color: #35c156;
|
||||
}
|
||||
@ -1332,6 +1336,28 @@ div.fb_iframe_widget > span {
|
||||
background: #1e84a5;
|
||||
}
|
||||
|
||||
|
||||
table.compare-table td {
|
||||
height: 70px;
|
||||
vertical-align: middle !important;
|
||||
}
|
||||
table.compare-table th {
|
||||
height: 70px;
|
||||
vertical-align: middle !important;
|
||||
text-align: center;
|
||||
color: white;
|
||||
}
|
||||
table.compare-table td:first-child {
|
||||
text-align: left;
|
||||
}
|
||||
table.compare-table-free th {
|
||||
background-color: #0b4d78;
|
||||
}
|
||||
table.compare-table-paid th {
|
||||
background-color: #e37329;
|
||||
}
|
||||
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.hide-desktop {display: none !important;}
|
||||
}
|
||||
|
@ -1563,7 +1563,7 @@ function displayInvoiceHeader(doc, invoice, layout) {
|
||||
doc.text(layout.marginLeft, layout.tableTop, invoiceLabels.item);
|
||||
doc.text(layout.descriptionLeft, layout.tableTop, invoiceLabels.description);
|
||||
doc.text(costX, layout.tableTop, invoiceLabels.unit_cost);
|
||||
if (invoice.account.hide_quantity === '0') {
|
||||
if (invoice.account.hide_quantity != '1') {
|
||||
doc.text(qtyX, layout.tableTop, invoiceLabels.quantity);
|
||||
}
|
||||
doc.text(totalX, layout.tableTop, invoiceLabels.line_total);
|
||||
@ -1582,7 +1582,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
var shownItem = false;
|
||||
var currencyId = invoice && invoice.client ? invoice.client.currency_id : 1;
|
||||
var tableTop = layout.tableTop;
|
||||
var hideQuantity = invoice.account.hide_quantity === '1';
|
||||
var hideQuantity = invoice.account.hide_quantity == '1';
|
||||
|
||||
doc.setFontSize(8);
|
||||
for (var i=0; i<invoice.invoice_items.length; i++) {
|
||||
@ -1636,7 +1636,7 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
if (lineTotal) {
|
||||
total += lineTotal;
|
||||
}
|
||||
lineTotal = formatMoney(lineTotal, currencyId, true);
|
||||
lineTotal = formatMoney(lineTotal, currencyId);
|
||||
|
||||
var costX = layout.unitCostRight - (doc.getStringUnitWidth(cost) * doc.internal.getFontSize());
|
||||
var qtyX = layout.qtyRight - (doc.getStringUnitWidth(qty) * doc.internal.getFontSize());
|
||||
|
Loading…
Reference in New Issue
Block a user