invoice/bill label
This commit is contained in:
		| @@ -9,10 +9,40 @@ class BillStatus extends Model | |||||||
|  |  | ||||||
|     protected $table = 'bill_statuses'; |     protected $table = 'bill_statuses'; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * The accessors to append to the model's array form. | ||||||
|  |      * | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $appends = ['label']; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Attributes that should be mass-assignable. |      * Attributes that should be mass-assignable. | ||||||
|      * |      * | ||||||
|      * @var array |      * @var array | ||||||
|      */ |      */ | ||||||
|     protected $fillable = ['company_id', 'name', 'code']; |     protected $fillable = ['company_id', 'name', 'code']; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the status label. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getLabelAttribute() | ||||||
|  |     { | ||||||
|  |         switch ($this->code) { | ||||||
|  |             case 'paid': | ||||||
|  |                 $label = 'label-success'; | ||||||
|  |                 break; | ||||||
|  |             case 'partial': | ||||||
|  |             case 'received': | ||||||
|  |                 $label = 'label-warning'; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 $label = 'bg-aqua'; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $label; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,10 +9,40 @@ class InvoiceStatus extends Model | |||||||
|  |  | ||||||
|     protected $table = 'invoice_statuses'; |     protected $table = 'invoice_statuses'; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * The accessors to append to the model's array form. | ||||||
|  |      * | ||||||
|  |      * @var array | ||||||
|  |      */ | ||||||
|  |     protected $appends = ['label']; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Attributes that should be mass-assignable. |      * Attributes that should be mass-assignable. | ||||||
|      * |      * | ||||||
|      * @var array |      * @var array | ||||||
|      */ |      */ | ||||||
|     protected $fillable = ['company_id', 'name', 'code']; |     protected $fillable = ['company_id', 'name', 'code']; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Get the status label. | ||||||
|  |      * | ||||||
|  |      * @return string | ||||||
|  |      */ | ||||||
|  |     public function getLabelAttribute() | ||||||
|  |     { | ||||||
|  |         switch ($this->code) { | ||||||
|  |             case 'paid': | ||||||
|  |                 $label = 'label-success'; | ||||||
|  |                 break; | ||||||
|  |             case 'partial': | ||||||
|  |             case 'sent': | ||||||
|  |                 $label = 'label-warning'; | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 $label = 'bg-aqua'; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $label; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -45,26 +45,13 @@ | |||||||
|                 </thead> |                 </thead> | ||||||
|                 <tbody> |                 <tbody> | ||||||
|                 @foreach($bills as $item) |                 @foreach($bills as $item) | ||||||
|                     @php |  | ||||||
|                         switch ($item->status->code) { |  | ||||||
|                             case 'paid': |  | ||||||
|                                 $label = 'label-success'; |  | ||||||
|                                 break; |  | ||||||
|                             case 'partial': |  | ||||||
|                                 $label = 'label-warning'; |  | ||||||
|                                 break; |  | ||||||
|                             default: |  | ||||||
|                                 $label = 'bg-aqua'; |  | ||||||
|                                 break; |  | ||||||
|                         } |  | ||||||
|                     @endphp |  | ||||||
|                     <tr> |                     <tr> | ||||||
|                         <td><a href="{{ url('expenses/bills/' . $item->id . ' ') }}">{{ $item->bill_number }}</a></td> |                         <td><a href="{{ url('expenses/bills/' . $item->id . ' ') }}">{{ $item->bill_number }}</a></td> | ||||||
|                         <td>{{ $item->vendor_name }}</td> |                         <td>{{ $item->vendor_name }}</td> | ||||||
|                         <td>@money($item->amount, $item->currency_code, true)</td> |                         <td>@money($item->amount, $item->currency_code, true)</td> | ||||||
|                         <td>{{ Date::parse($item->billed_at)->format($date_format) }}</td> |                         <td>{{ Date::parse($item->billed_at)->format($date_format) }}</td> | ||||||
|                         <td>{{ Date::parse($item->due_at)->format($date_format) }}</td> |                         <td>{{ Date::parse($item->due_at)->format($date_format) }}</td> | ||||||
|                         <td><span class="label {{ $label }}">{{ $item->status->name }}</span></td> |                         <td><span class="label {{ $item->status->label }}">{{ $item->status->name }}</span></td> | ||||||
|                         <td class="text-center"> |                         <td class="text-center"> | ||||||
|                             <div class="btn-group"> |                             <div class="btn-group"> | ||||||
|                                 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false"> |                                 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false"> | ||||||
|   | |||||||
| @@ -44,26 +44,13 @@ | |||||||
|                 </thead> |                 </thead> | ||||||
|                 <tbody> |                 <tbody> | ||||||
|                 @foreach($invoices as $item) |                 @foreach($invoices as $item) | ||||||
|                     @php |  | ||||||
|                     switch ($item->status->code) { |  | ||||||
|                         case 'paid': |  | ||||||
|                             $label = 'label-success'; |  | ||||||
|                             break; |  | ||||||
|                         case 'partial': |  | ||||||
|                             $label = 'label-warning'; |  | ||||||
|                             break; |  | ||||||
|                         default: |  | ||||||
|                             $label = 'bg-aqua'; |  | ||||||
|                             break; |  | ||||||
|                     } |  | ||||||
|                     @endphp |  | ||||||
|                     <tr> |                     <tr> | ||||||
|                         <td><a href="{{ url('incomes/invoices/' . $item->id . ' ') }}">{{ $item->invoice_number }}</a></td> |                         <td><a href="{{ url('incomes/invoices/' . $item->id . ' ') }}">{{ $item->invoice_number }}</a></td> | ||||||
|                         <td>{{ $item->customer_name }}</td> |                         <td>{{ $item->customer_name }}</td> | ||||||
|                         <td>@money($item->amount, $item->currency_code, true)</td> |                         <td>@money($item->amount, $item->currency_code, true)</td> | ||||||
|                         <td>{{ Date::parse($item->invoiced_at)->format($date_format) }}</td> |                         <td>{{ Date::parse($item->invoiced_at)->format($date_format) }}</td> | ||||||
|                         <td>{{ Date::parse($item->due_at)->format($date_format) }}</td> |                         <td>{{ Date::parse($item->due_at)->format($date_format) }}</td> | ||||||
|                         <td><span class="label {{ $label }}">{{ $item->status->name }}</span></td> |                         <td><span class="label {{ $item->status->label }}">{{ $item->status->name }}</span></td> | ||||||
|                         <td class="text-center"> |                         <td class="text-center"> | ||||||
|                             <div class="btn-group"> |                             <div class="btn-group"> | ||||||
|                                 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false"> |                                 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user