mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-30 21:21:09 -04:00 
			
		
		
		
	Compare commits
	
		
			76 Commits
		
	
	
		
			mail-sende
			...
			dark-mode
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 7b9c7c3528 | |||
| d1ab4a8021 | |||
| 45aaee72d8 | |||
| f4bc78ce98 | |||
| ba769864d4 | |||
| de235a91e5 | |||
| 18dc88682c | |||
| deb039ba02 | |||
| 7e80bfb507 | |||
| 8a5632c7d6 | |||
| 1a4309ca69 | |||
| 3b3da13218 | |||
| 5440b0f354 | |||
| 9249105ad6 | |||
| 238cdb3c25 | |||
| 55bf70c868 | |||
| 0c5adff9b4 | |||
| 3d5732ee26 | |||
| 5aa7decdbe | |||
| 5c67780870 | |||
| ba7f619c67 | |||
| 82efad71c0 | |||
| 826ef72faa | |||
| 2adaa7a84a | |||
| 13557ea075 | |||
| ce88c772d1 | |||
| a32d36363d | |||
| f874b3507d | |||
| c36d25931f | |||
| 1e6c3b287f | |||
| 0462ff60a0 | |||
| 29a135adaf | |||
| 1aceb2c672 | |||
| fb9fab641d | |||
| 8f2edc220b | |||
| d14ab013ad | |||
| f6639f5863 | |||
| c5acf1343e | |||
| 0321ca5515 | |||
| bd345949e5 | |||
| b4b00ebdd6 | |||
| 43316dae28 | |||
| 80e2548b38 | |||
| e8d92cd641 | |||
| 2c8bb38531 | |||
| 04c7ae39a2 | |||
| af2482a69c | |||
| cac35826c2 | |||
| 18b5705372 | |||
| c61fbad5ce | |||
| 15f3f566e3 | |||
| 2e93082282 | |||
| ca55221c4f | |||
| 98196194e2 | |||
| df04fd9e53 | |||
| 189c51cdf4 | |||
| bd5f0fe5cf | |||
| 787619b907 | |||
| fd70ab9a99 | |||
| 33315638df | |||
| bba14bf51a | |||
| ea41989034 | |||
| 3f3f83a00a | |||
| adc5962071 | |||
| c4c00002d7 | |||
| a7c1e12db6 | |||
| 32949d1eec | |||
| 7718f77f3d | |||
| a9e54981bf | |||
| ef35293f8a | |||
| 5c63770b6b | |||
| d130e20c92 | |||
| 586fb1ae10 | |||
| 20c2502e31 | |||
| 0e31f85c18 | |||
| e7301eb7a3 | 
							
								
								
									
										9
									
								
								.github/workflows/uffizzi-build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								.github/workflows/uffizzi-build.yml
									
									
									
									
										vendored
									
									
								
							| @ -14,6 +14,8 @@ jobs: | |||||||
|     steps: |     steps: | ||||||
|       - name: Checkout git repo |       - name: Checkout git repo | ||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
|  |       - name: Set up Docker Buildx | ||||||
|  |         uses: docker/setup-buildx-action@v2         | ||||||
|       - name: Generate UUID image name |       - name: Generate UUID image name | ||||||
|         id: uuid |         id: uuid | ||||||
|         run: echo "UUID_TAG_APP=$(uuidgen)" >> $GITHUB_ENV |         run: echo "UUID_TAG_APP=$(uuidgen)" >> $GITHUB_ENV | ||||||
| @ -31,10 +33,11 @@ jobs: | |||||||
|           tags: ${{ steps.meta.outputs.tags }} |           tags: ${{ steps.meta.outputs.tags }} | ||||||
|           labels: ${{ steps.meta.outputs.labels }} |           labels: ${{ steps.meta.outputs.labels }} | ||||||
|           file: ./uffizzi/Dockerfile |           file: ./uffizzi/Dockerfile | ||||||
|  |           cache-from: type=gha | ||||||
|  |           cache-to: type=gha,mode=max | ||||||
|  |  | ||||||
|  |  | ||||||
|   build-nginx: |   build-nginx: | ||||||
|     needs:  |  | ||||||
|       - build-application |  | ||||||
|     name: Build and Push `nginx` |     name: Build and Push `nginx` | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }} |     if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }} | ||||||
| @ -62,8 +65,6 @@ jobs: | |||||||
|           tags: ${{ steps.meta.outputs.tags }} |           tags: ${{ steps.meta.outputs.tags }} | ||||||
|           labels: ${{ steps.meta.outputs.labels }} |           labels: ${{ steps.meta.outputs.labels }} | ||||||
|           file: ./uffizzi/nginx/Dockerfile |           file: ./uffizzi/nginx/Dockerfile | ||||||
|           build-args: | |  | ||||||
|             BASE_IMAGE=${{ needs.build-application.outputs.tags }} |  | ||||||
|           cache-from: type=gha |           cache-from: type=gha | ||||||
|           cache-to: type=gha,mode=max |           cache-to: type=gha,mode=max | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -17,4 +17,3 @@ Homestead.yaml | |||||||
| /public/docs | /public/docs | ||||||
| /.scribe | /.scribe | ||||||
| !storage/fonts/.gitkeep | !storage/fonts/.gitkeep | ||||||
| .DS_Store |  | ||||||
|  | |||||||
| @ -55,7 +55,7 @@ class CreateTemplateCommand extends Command | |||||||
|         copy(public_path("/build/img/PDF/{$type}1.png"), public_path("/build/img/PDF/{$templateName}.png")); |         copy(public_path("/build/img/PDF/{$type}1.png"), public_path("/build/img/PDF/{$templateName}.png")); | ||||||
|         copy(resource_path("/static/img/PDF/{$type}1.png"), resource_path("/static/img/PDF/{$templateName}.png")); |         copy(resource_path("/static/img/PDF/{$type}1.png"), resource_path("/static/img/PDF/{$templateName}.png")); | ||||||
|  |  | ||||||
|         $path = resource_path("views/app/pdf/{$type}/{$templateName}.blade.php"); |         $path = resource_path("app/pdf/{$type}/{$templateName}.blade.php"); | ||||||
|         $type = ucfirst($type); |         $type = ucfirst($type); | ||||||
|         $this->info("{$type} Template created successfully at ".$path); |         $this->info("{$type} Template created successfully at ".$path); | ||||||
|  |  | ||||||
|  | |||||||
| @ -103,6 +103,7 @@ class CustomerStatsController extends Controller | |||||||
|         ) |         ) | ||||||
|             ->whereCompany() |             ->whereCompany() | ||||||
|             ->whereCustomer($customer->id) |             ->whereCustomer($customer->id) | ||||||
|  |             ->where('status', '<>', Invoice::STATUS_DRAFT) | ||||||
|             ->sum('total'); |             ->sum('total'); | ||||||
|         $totalReceipts = Payment::whereBetween( |         $totalReceipts = Payment::whereBetween( | ||||||
|             'payment_date', |             'payment_date', | ||||||
|  | |||||||
| @ -104,6 +104,7 @@ class DashboardController extends Controller | |||||||
|             'invoice_date', |             'invoice_date', | ||||||
|             [$startDate->format('Y-m-d'), $start->format('Y-m-d')] |             [$startDate->format('Y-m-d'), $start->format('Y-m-d')] | ||||||
|         ) |         ) | ||||||
|  |             ->where('status', '<>', Invoice::STATUS_DRAFT) | ||||||
|             ->whereCompany() |             ->whereCompany() | ||||||
|             ->sum('base_total'); |             ->sum('base_total'); | ||||||
|  |  | ||||||
| @ -141,6 +142,7 @@ class DashboardController extends Controller | |||||||
|         $recent_due_invoices = Invoice::with('customer') |         $recent_due_invoices = Invoice::with('customer') | ||||||
|             ->whereCompany() |             ->whereCompany() | ||||||
|             ->where('base_due_amount', '>', 0) |             ->where('base_due_amount', '>', 0) | ||||||
|  |             ->where('status', '<>', Invoice::STATUS_DRAFT) | ||||||
|             ->take(5) |             ->take(5) | ||||||
|             ->latest() |             ->latest() | ||||||
|             ->get(); |             ->get(); | ||||||
|  | |||||||
| @ -24,6 +24,7 @@ class InvoicesController extends Controller | |||||||
|         $limit = $request->has('limit') ? $request->limit : 10; |         $limit = $request->has('limit') ? $request->limit : 10; | ||||||
|  |  | ||||||
|         $invoices = Invoice::whereCompany() |         $invoices = Invoice::whereCompany() | ||||||
|  |             ->whereTabFilters($request->tab_status) | ||||||
|             ->join('customers', 'customers.id', '=', 'invoices.customer_id') |             ->join('customers', 'customers.id', '=', 'invoices.customer_id') | ||||||
|             ->applyFilters($request->all()) |             ->applyFilters($request->all()) | ||||||
|             ->select('invoices.*', 'customers.name') |             ->select('invoices.*', 'customers.name') | ||||||
|  | |||||||
| @ -1,24 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Http\Controllers\V1\Admin\MailSender; |  | ||||||
|  |  | ||||||
| use Crater\Http\Controllers\Controller; |  | ||||||
| use Crater\Http\Resources\MailSenderResource; |  | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Illuminate\Http\Request; |  | ||||||
|  |  | ||||||
| class GetAllMailSendersController extends Controller |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * Handle the incoming request. |  | ||||||
|      * |  | ||||||
|      * @param  \Illuminate\Http\Request  $request |  | ||||||
|      * @return \Illuminate\Http\Response |  | ||||||
|      */ |  | ||||||
|     public function __invoke(Request $request) |  | ||||||
|     { |  | ||||||
|         $mailSenders = MailSender::whereCompany()->get(); |  | ||||||
|  |  | ||||||
|         return MailSenderResource::collection($mailSenders); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,98 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Http\Controllers\V1\Admin\MailSender; |  | ||||||
|  |  | ||||||
| use Crater\Http\Controllers\Controller; |  | ||||||
| use Crater\Http\Requests\MailSenderRequest; |  | ||||||
| use Crater\Http\Resources\MailSenderResource; |  | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Illuminate\Http\Request; |  | ||||||
|  |  | ||||||
| class MailSenderController extends Controller |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * Display a listing of the resource. |  | ||||||
|      * |  | ||||||
|      * @return \Illuminate\Http\Response |  | ||||||
|      */ |  | ||||||
|     public function index(Request $request) |  | ||||||
|     { |  | ||||||
|         $this->authorize('viewAny', MailSender::class); |  | ||||||
|  |  | ||||||
|         $limit = $request->has('limit') ? $request->limit : 10; |  | ||||||
|  |  | ||||||
|         $mailSenders = MailSender::whereCompany() |  | ||||||
|             ->applyFilters($request->all()) |  | ||||||
|             ->paginateData($limit); |  | ||||||
|  |  | ||||||
|         return (MailSenderResource::collection($mailSenders)) |  | ||||||
|             ->additional(['meta' => [ |  | ||||||
|                 'mail_sender_total_count' => MailSender::whereCompany()->count(), |  | ||||||
|             ]]); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|      /** |  | ||||||
|      * Store a newly created resource in storage. |  | ||||||
|      * |  | ||||||
|      * @param  \Illuminate\Http\Request  $request |  | ||||||
|      * @return \Illuminate\Http\Response |  | ||||||
|      */ |  | ||||||
|     public function store(MailSenderRequest $request) |  | ||||||
|     { |  | ||||||
|         $this->authorize('create', MailSender::class); |  | ||||||
|  |  | ||||||
|         $mailSender = MailSender::createFromRequest($request); |  | ||||||
|  |  | ||||||
|         return new MailSenderResource($mailSender); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Display the specified resource. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\SenderMail  $senderMail |  | ||||||
|      * @return \Illuminate\Http\Response |  | ||||||
|      */ |  | ||||||
|     public function show(MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         $this->authorize('view', $mailSender); |  | ||||||
|  |  | ||||||
|         return new MailSenderResource($mailSender); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Update the specified resource in storage. |  | ||||||
|      * |  | ||||||
|      * @param  \Illuminate\Http\Request  $request |  | ||||||
|      * @param  \Crater\Models\SenderMail  $senderMail |  | ||||||
|      * @return \Illuminate\Http\Response |  | ||||||
|      */ |  | ||||||
|     public function update(MailSenderRequest $request, MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         $this->authorize('update', $mailSender); |  | ||||||
|  |  | ||||||
|         $mailSender->updateFromRequest($request); |  | ||||||
|  |  | ||||||
|         return new MailSenderResource($mailSender); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Remove the specified resource from storage. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\SenderMail  $senderMail |  | ||||||
|      * @return \Illuminate\Http\Response |  | ||||||
|      */ |  | ||||||
|     public function destroy(MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         $this->authorize('delete', $mailSender); |  | ||||||
|  |  | ||||||
|         if ($mailSender->is_default) { |  | ||||||
|            return respondJson('You can\'t remove default mail sender.', 'You can\'t remove default mail sender.'); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         $mailSender->delete(); |  | ||||||
|  |  | ||||||
|         return response()->json([ |  | ||||||
|             'success' => true, |  | ||||||
|         ]); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -3,29 +3,80 @@ | |||||||
| namespace Crater\Http\Controllers\V1\Admin\Settings; | namespace Crater\Http\Controllers\V1\Admin\Settings; | ||||||
|  |  | ||||||
| use Crater\Http\Controllers\Controller; | use Crater\Http\Controllers\Controller; | ||||||
| use Crater\Http\Requests\TestMailDriverRequest; | use Crater\Http\Requests\MailEnvironmentRequest; | ||||||
| use Crater\Mail\TestMail; | use Crater\Mail\TestMail; | ||||||
| use Crater\Models\MailSender; | use Crater\Models\Setting; | ||||||
|  | use Crater\Space\EnvironmentManager; | ||||||
|  | use Illuminate\Http\JsonResponse; | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
| use Mail; | use Mail; | ||||||
|  |  | ||||||
| class MailConfigurationController extends Controller | class MailConfigurationController extends Controller | ||||||
| { | { | ||||||
|     public function TestMailDriver(TestMailDriverRequest $request) |     /** | ||||||
|  |      * @var EnvironmentManager | ||||||
|  |      */ | ||||||
|  |     protected $environmentManager; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @param EnvironmentManager $environmentManager | ||||||
|  |      */ | ||||||
|  |     public function __construct(EnvironmentManager $environmentManager) | ||||||
|  |     { | ||||||
|  |         $this->environmentManager = $environmentManager; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * | ||||||
|  |      * @param MailEnvironmentRequest $request | ||||||
|  |      * @return JsonResponse | ||||||
|  |      */ | ||||||
|  |     public function saveMailEnvironment(MailEnvironmentRequest $request) | ||||||
|     { |     { | ||||||
|         $this->authorize('manage email config'); |         $this->authorize('manage email config'); | ||||||
|  |  | ||||||
|         MailSender::setMailConfiguration($request->mail_sender_id); |         $setting = Setting::getSetting('profile_complete'); | ||||||
|  |         $results = $this->environmentManager->saveMailVariables($request); | ||||||
|  |  | ||||||
|         Mail::to($request->to)->send(new TestMail($request->subject, $request->message)); |         if ($setting !== 'COMPLETED') { | ||||||
|  |             Setting::setSetting('profile_complete', 4); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         return response()->json([ |         return response()->json($results); | ||||||
|             'success' => true, |  | ||||||
|         ]); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getMailDrivers(Request $request) |     public function getMailEnvironment() | ||||||
|     { |     { | ||||||
|  |         $this->authorize('manage email config'); | ||||||
|  |  | ||||||
|  |         $MailData = [ | ||||||
|  |             'mail_driver' => config('mail.driver'), | ||||||
|  |             'mail_host' => config('mail.host'), | ||||||
|  |             'mail_port' => config('mail.port'), | ||||||
|  |             'mail_username' => config('mail.username'), | ||||||
|  |             'mail_password' => config('mail.password'), | ||||||
|  |             'mail_encryption' => config('mail.encryption'), | ||||||
|  |             'from_name' => config('mail.from.name'), | ||||||
|  |             'from_mail' => config('mail.from.address'), | ||||||
|  |             'mail_mailgun_endpoint' => config('services.mailgun.endpoint'), | ||||||
|  |             'mail_mailgun_domain' => config('services.mailgun.domain'), | ||||||
|  |             'mail_mailgun_secret' => config('services.mailgun.secret'), | ||||||
|  |             'mail_ses_key' => config('services.ses.key'), | ||||||
|  |             'mail_ses_secret' => config('services.ses.secret'), | ||||||
|  |         ]; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         return response()->json($MailData); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * | ||||||
|  |      * @return JsonResponse | ||||||
|  |      */ | ||||||
|  |     public function getMailDrivers() | ||||||
|  |     { | ||||||
|  |         $this->authorize('manage email config'); | ||||||
|  |  | ||||||
|         $drivers = [ |         $drivers = [ | ||||||
|             'smtp', |             'smtp', | ||||||
|             'mail', |             'mail', | ||||||
| @ -36,4 +87,21 @@ class MailConfigurationController extends Controller | |||||||
|  |  | ||||||
|         return response()->json($drivers); |         return response()->json($drivers); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public function testEmailConfig(Request $request) | ||||||
|  |     { | ||||||
|  |         $this->authorize('manage email config'); | ||||||
|  |  | ||||||
|  |         $this->validate($request, [ | ||||||
|  |             'to' => 'required|email', | ||||||
|  |             'subject' => 'required', | ||||||
|  |             'message' => 'required', | ||||||
|  |         ]); | ||||||
|  |  | ||||||
|  |         Mail::to($request->to)->send(new TestMail($request->subject, $request->message)); | ||||||
|  |  | ||||||
|  |         return response()->json([ | ||||||
|  |             'success' => true, | ||||||
|  |         ]); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ use Crater\Models\CompanySetting; | |||||||
| use Crater\Models\Customer; | use Crater\Models\Customer; | ||||||
| use Crater\Models\EmailLog; | use Crater\Models\EmailLog; | ||||||
| use Crater\Models\Estimate; | use Crater\Models\Estimate; | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
|  |  | ||||||
| class EstimatePdfController extends Controller | class EstimatePdfController extends Controller | ||||||
| @ -28,16 +27,14 @@ class EstimatePdfController extends Controller | |||||||
|                 ); |                 ); | ||||||
|  |  | ||||||
|                 if ($notifyEstimateViewed == 'YES') { |                 if ($notifyEstimateViewed == 'YES') { | ||||||
|                     $notificationEmail = CompanySetting::getSetting('notification_email', $estimate->company_id); |  | ||||||
|                     $mailSender = MailSender::where('company_id', $estimate->company_id)->where('is_default', true)->first(); |  | ||||||
|                     MailSender::setMailConfiguration($mailSender->id); |  | ||||||
|  |  | ||||||
|                     $data['from_address'] = $mailSender->from_address; |  | ||||||
|                     $data['from_name'] = $mailSender->from_name; |  | ||||||
|                     $data['user'] = Customer::find($estimate->customer_id)->toArray(); |  | ||||||
|                     $data['estimate'] = Estimate::findOrFail($estimate->id)->toArray(); |                     $data['estimate'] = Estimate::findOrFail($estimate->id)->toArray(); | ||||||
|  |                     $data['user'] = Customer::find($estimate->customer_id)->toArray(); | ||||||
|  |                     $notificationEmail = CompanySetting::getSetting( | ||||||
|  |                         'notification_email', | ||||||
|  |                         $estimate->company_id | ||||||
|  |                     ); | ||||||
|  |  | ||||||
|                     send_mail(new EstimateViewedMail($data), $mailSender, $notificationEmail); |                     \Mail::to($notificationEmail)->send(new EstimateViewedMail($data)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ use Crater\Models\CompanySetting; | |||||||
| use Crater\Models\Customer; | use Crater\Models\Customer; | ||||||
| use Crater\Models\EmailLog; | use Crater\Models\EmailLog; | ||||||
| use Crater\Models\Invoice; | use Crater\Models\Invoice; | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||||
|  |  | ||||||
| class InvoicePdfController extends Controller | class InvoicePdfController extends Controller | ||||||
| @ -29,16 +28,14 @@ class InvoicePdfController extends Controller | |||||||
|                 ); |                 ); | ||||||
|  |  | ||||||
|                 if ($notifyInvoiceViewed == 'YES') { |                 if ($notifyInvoiceViewed == 'YES') { | ||||||
|                     $notificationEmail = CompanySetting::getSetting('notification_email', $invoice->company_id); |  | ||||||
|                     $mailSender = MailSender::where('company_id', $invoice->company_id)->where('is_default', true)->first(); |  | ||||||
|                     MailSender::setMailConfiguration($mailSender->id); |  | ||||||
|  |  | ||||||
|                     $data['from_address'] = $mailSender->from_address; |  | ||||||
|                     $data['from_name'] = $mailSender->from_name; |  | ||||||
|                     $data['invoice'] = Invoice::findOrFail($invoice->id)->toArray(); |                     $data['invoice'] = Invoice::findOrFail($invoice->id)->toArray(); | ||||||
|                     $data['user'] = Customer::find($invoice->customer_id)->toArray(); |                     $data['user'] = Customer::find($invoice->customer_id)->toArray(); | ||||||
|  |                     $notificationEmail = CompanySetting::getSetting( | ||||||
|  |                         'notification_email', | ||||||
|  |                         $invoice->company_id | ||||||
|  |                     ); | ||||||
|  |  | ||||||
|                     send_mail(new InvoiceViewedMail($data), $mailSender, $notificationEmail); |                     \Mail::to($notificationEmail)->send(new InvoiceViewedMail($data)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | |||||||
| @ -4,7 +4,6 @@ namespace Crater\Http\Middleware; | |||||||
|  |  | ||||||
| use Closure; | use Closure; | ||||||
| use Crater\Models\FileDisk; | use Crater\Models\FileDisk; | ||||||
| use Crater\Models\MailSender; |  | ||||||
|  |  | ||||||
| class ConfigMiddleware | class ConfigMiddleware | ||||||
| { | { | ||||||
| @ -29,12 +28,6 @@ class ConfigMiddleware | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $default_mail_sender = MailSender::where('company_id', $request->header('company'))->where('is_default', true)->first(); |  | ||||||
|  |  | ||||||
|         if ($default_mail_sender) { |  | ||||||
|             $default_mail_sender->setMailConfiguration($default_mail_sender->id); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return $next($request); |         return $next($request); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,7 +3,6 @@ | |||||||
| namespace Crater\Http\Requests; | namespace Crater\Http\Requests; | ||||||
|  |  | ||||||
| use Illuminate\Foundation\Http\FormRequest; | use Illuminate\Foundation\Http\FormRequest; | ||||||
| use Illuminate\Support\Str; |  | ||||||
| use Illuminate\Validation\Rule; | use Illuminate\Validation\Rule; | ||||||
|  |  | ||||||
| class CompaniesRequest extends FormRequest | class CompaniesRequest extends FormRequest | ||||||
| @ -34,6 +33,10 @@ class CompaniesRequest extends FormRequest | |||||||
|             'currency' => [ |             'currency' => [ | ||||||
|                 'required' |                 'required' | ||||||
|             ], |             ], | ||||||
|  |             'slug' => [ | ||||||
|  |                 'required', | ||||||
|  |                 Rule::unique('companies') | ||||||
|  |             ], | ||||||
|             'address.name' => [ |             'address.name' => [ | ||||||
|                 'nullable', |                 'nullable', | ||||||
|             ], |             ], | ||||||
| @ -68,11 +71,11 @@ class CompaniesRequest extends FormRequest | |||||||
|     { |     { | ||||||
|         return collect($this->validated()) |         return collect($this->validated()) | ||||||
|             ->only([ |             ->only([ | ||||||
|                 'name' |                 'name', | ||||||
|  |                 'slug' | ||||||
|             ]) |             ]) | ||||||
|             ->merge([ |             ->merge([ | ||||||
|                 'owner_id' => $this->user()->id, |                 'owner_id' => $this->user()->id | ||||||
|                 'slug' => Str::slug($this->name) |  | ||||||
|             ]) |             ]) | ||||||
|             ->toArray(); |             ->toArray(); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -30,7 +30,8 @@ class CompanyRequest extends FormRequest | |||||||
|                 Rule::unique('companies')->ignore($this->header('company'), 'id'), |                 Rule::unique('companies')->ignore($this->header('company'), 'id'), | ||||||
|             ], |             ], | ||||||
|             'slug' => [ |             'slug' => [ | ||||||
|                 'nullable' |                 'required', | ||||||
|  |                 Rule::unique('companies')->ignore($this->header('company'), 'id'), | ||||||
|             ], |             ], | ||||||
|             'address.country_id' => [ |             'address.country_id' => [ | ||||||
|                 'required', |                 'required', | ||||||
|  | |||||||
| @ -1,85 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Http\Requests; |  | ||||||
|  |  | ||||||
| use Illuminate\Validation\Rule; |  | ||||||
| use Illuminate\Foundation\Http\FormRequest; |  | ||||||
|  |  | ||||||
| class MailSenderRequest extends FormRequest |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * Determine if the user is authorized to make this request. |  | ||||||
|      * |  | ||||||
|      * @return bool |  | ||||||
|      */ |  | ||||||
|     public function authorize() |  | ||||||
|     { |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Get the validation rules that apply to the request. |  | ||||||
|      * |  | ||||||
|      * @return array |  | ||||||
|      */ |  | ||||||
|     public function rules() |  | ||||||
|     { |  | ||||||
|         $rules = [ |  | ||||||
|             'name' => [ |  | ||||||
|                 'required', |  | ||||||
|                 Rule::unique('mail_senders') |  | ||||||
|                 ->where('company_id', $this->header('company')) |  | ||||||
|             ], |  | ||||||
|             'driver' => [ |  | ||||||
|                 'required', |  | ||||||
|             ], |  | ||||||
|             'is_default' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ], |  | ||||||
|             'bcc' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ], |  | ||||||
|             'cc' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ], |  | ||||||
|             'from_address' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ], |  | ||||||
|             'from_name' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ], |  | ||||||
|             'settings' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ], |  | ||||||
|             'settings.*' => [ |  | ||||||
|                 'nullable' |  | ||||||
|             ] |  | ||||||
|         ]; |  | ||||||
|  |  | ||||||
|         if ($this->isMethod('PUT')) { |  | ||||||
|             $rules['name'] = [ |  | ||||||
|                 'nullable', |  | ||||||
|                 Rule::unique('mail_senders') |  | ||||||
|                     ->ignore($this->route('mail_sender')->id) |  | ||||||
|                     ->where('company_id', $this->header('company')) |  | ||||||
|             ]; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return $rules; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function getMailSenderPayload() |  | ||||||
|     { |  | ||||||
|         $data = $this->validated(); |  | ||||||
|  |  | ||||||
|         if ($data['settings'] && $data['settings']['encryption'] == 'none') { |  | ||||||
|             $data['settings']['encryption'] = ''; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return collect($data) |  | ||||||
|             ->merge([ |  | ||||||
|                 'company_id' => $this->header('company'), |  | ||||||
|             ]) |  | ||||||
|             ->toArray(); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -30,7 +30,7 @@ class SendEstimatesRequest extends FormRequest | |||||||
|             'body' => [ |             'body' => [ | ||||||
|                 'required', |                 'required', | ||||||
|             ], |             ], | ||||||
|             'mail_sender_id' => [ |             'from' => [ | ||||||
|                 'required', |                 'required', | ||||||
|             ], |             ], | ||||||
|             'to' => [ |             'to' => [ | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class SendInvoiceRequest extends FormRequest | |||||||
|             'subject' => [ |             'subject' => [ | ||||||
|                 'required', |                 'required', | ||||||
|             ], |             ], | ||||||
|             'mail_sender_id' => [ |             'from' => [ | ||||||
|                 'required', |                 'required', | ||||||
|             ], |             ], | ||||||
|             'to' => [ |             'to' => [ | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class SendPaymentRequest extends FormRequest | |||||||
|             'body' => [ |             'body' => [ | ||||||
|                 'required', |                 'required', | ||||||
|             ], |             ], | ||||||
|             'mail_sender_id' => [ |             'from' => [ | ||||||
|                 'required', |                 'required', | ||||||
|             ], |             ], | ||||||
|             'to' => [ |             'to' => [ | ||||||
|  | |||||||
| @ -1,39 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Http\Requests; |  | ||||||
|  |  | ||||||
| use Illuminate\Foundation\Http\FormRequest; |  | ||||||
|  |  | ||||||
| class TestMailDriverRequest extends FormRequest |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * Determine if the user is authorized to make this request. |  | ||||||
|      * |  | ||||||
|      * @return bool |  | ||||||
|      */ |  | ||||||
|     public function authorize() |  | ||||||
|     { |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Get the validation rules that apply to the request. |  | ||||||
|      * |  | ||||||
|      * @return array |  | ||||||
|      */ |  | ||||||
|     public function rules() |  | ||||||
|     { |  | ||||||
|         return [ |  | ||||||
|             'to' => [ |  | ||||||
|                 'required', |  | ||||||
|                 'email' |  | ||||||
|             ], |  | ||||||
|             'subject' => [ |  | ||||||
|                 'required' |  | ||||||
|             ], |  | ||||||
|             'message' => [ |  | ||||||
|                 'required' |  | ||||||
|             ], |  | ||||||
|         ]; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -23,7 +23,7 @@ class EstimateResource extends JsonResource | |||||||
|             'reference_number' => $this->reference_number, |             'reference_number' => $this->reference_number, | ||||||
|             'tax_per_item' => $this->tax_per_item, |             'tax_per_item' => $this->tax_per_item, | ||||||
|             'discount_per_item' => $this->discount_per_item, |             'discount_per_item' => $this->discount_per_item, | ||||||
|             'notes' => $this->getNotes(), |             'notes' => $this->notes, | ||||||
|             'discount' => $this->discount, |             'discount' => $this->discount, | ||||||
|             'discount_type' => $this->discount_type, |             'discount_type' => $this->discount_type, | ||||||
|             'discount_val' => $this->discount_val, |             'discount_val' => $this->discount_val, | ||||||
|  | |||||||
| @ -1,30 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Http\Resources; |  | ||||||
|  |  | ||||||
| use Illuminate\Http\Resources\Json\JsonResource; |  | ||||||
|  |  | ||||||
| class MailSenderResource extends JsonResource |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * Transform the resource into an array. |  | ||||||
|      * |  | ||||||
|      * @param  \Illuminate\Http\Request  $request |  | ||||||
|      * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable |  | ||||||
|      */ |  | ||||||
|     public function toArray($request) |  | ||||||
|     { |  | ||||||
|         return [ |  | ||||||
|             'id' => $this->id, |  | ||||||
|             'name' => $this->name, |  | ||||||
|             'driver' => $this->driver, |  | ||||||
|             'is_default' => $this->is_default, |  | ||||||
|             'bcc' => $this->bcc, |  | ||||||
|             'cc' => $this->cc, |  | ||||||
|             'from_address' => $this->from_address, |  | ||||||
|             'from_name' => $this->from_name, |  | ||||||
|             'company_id' => $this->company_id, |  | ||||||
|             'settings' => $this->settings |  | ||||||
|         ]; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -18,7 +18,7 @@ class PaymentResource extends JsonResource | |||||||
|             'id' => $this->id, |             'id' => $this->id, | ||||||
|             'payment_number' => $this->payment_number, |             'payment_number' => $this->payment_number, | ||||||
|             'payment_date' => $this->payment_date, |             'payment_date' => $this->payment_date, | ||||||
|             'notes' => $this->getNotes(), |             'notes' => $this->notes, | ||||||
|             'amount' => $this->amount, |             'amount' => $this->amount, | ||||||
|             'unique_hash' => $this->unique_hash, |             'unique_hash' => $this->unique_hash, | ||||||
|             'invoice_id' => $this->invoice_id, |             'invoice_id' => $this->invoice_id, | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class EstimateViewedMail extends Mailable | |||||||
|      */ |      */ | ||||||
|     public function build() |     public function build() | ||||||
|     { |     { | ||||||
|         return $this->from($this->data['from_address'], $this->data['from_name']) |         return $this->from(config('mail.from.address'), config('mail.from.name')) | ||||||
|                     ->markdown('emails.viewed.estimate', ['data', $this->data]); |                     ->markdown('emails.viewed.estimate', ['data', $this->data]); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class InvoiceViewedMail extends Mailable | |||||||
|      */ |      */ | ||||||
|     public function build() |     public function build() | ||||||
|     { |     { | ||||||
|         return $this->from($this->data['from_address'], $this->data['from_name']) |         return $this->from(config('mail.from.address'), config('mail.from.name')) | ||||||
|                     ->markdown('emails.viewed.invoice', ['data', $this->data]); |                     ->markdown('emails.viewed.invoice', ['data', $this->data]); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ class SendEstimateMail extends Mailable | |||||||
|     public function build() |     public function build() | ||||||
|     { |     { | ||||||
|         $log = EmailLog::create([ |         $log = EmailLog::create([ | ||||||
|             'from' => $this->data['from_address'], |             'from' => $this->data['from'], | ||||||
|             'to' => $this->data['to'], |             'to' => $this->data['to'], | ||||||
|             'subject' => $this->data['subject'], |             'subject' => $this->data['subject'], | ||||||
|             'body' => $this->data['body'], |             'body' => $this->data['body'], | ||||||
| @ -47,10 +47,9 @@ class SendEstimateMail extends Mailable | |||||||
|  |  | ||||||
|         $this->data['url'] = route('estimate', ['email_log' => $log->token]); |         $this->data['url'] = route('estimate', ['email_log' => $log->token]); | ||||||
|  |  | ||||||
|         $mailContent = $this->from($this->data['from_address'], $this->data['from_name']) |         $mailContent = $this->from($this->data['from'], config('mail.from.name')) | ||||||
|             ->subject($this->data['subject']) |                     ->subject($this->data['subject']) | ||||||
|             ->markdown("emails.send.estimate", ['data', $this->data]); |                     ->markdown('emails.send.estimate', ['data', $this->data]); | ||||||
|  |  | ||||||
|  |  | ||||||
|         if ($this->data['attach']['data']) { |         if ($this->data['attach']['data']) { | ||||||
|             $mailContent->attachData( |             $mailContent->attachData( | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ class SendInvoiceMail extends Mailable | |||||||
|     public function build() |     public function build() | ||||||
|     { |     { | ||||||
|         $log = EmailLog::create([ |         $log = EmailLog::create([ | ||||||
|             'from' => $this->data['from_address'], |             'from' => $this->data['from'], | ||||||
|             'to' => $this->data['to'], |             'to' => $this->data['to'], | ||||||
|             'subject' => $this->data['subject'], |             'subject' => $this->data['subject'], | ||||||
|             'body' => $this->data['body'], |             'body' => $this->data['body'], | ||||||
| @ -47,9 +47,9 @@ class SendInvoiceMail extends Mailable | |||||||
|  |  | ||||||
|         $this->data['url'] = route('invoice', ['email_log' => $log->token]); |         $this->data['url'] = route('invoice', ['email_log' => $log->token]); | ||||||
|  |  | ||||||
|         $mailContent = $this->from($this->data['from_address'], $this->data['from_name']) |         $mailContent = $this->from($this->data['from'], config('mail.from.name')) | ||||||
|             ->subject($this->data['subject']) |             ->subject($this->data['subject']) | ||||||
|             ->markdown("emails.send.invoice", ['data', $this->data]); |             ->markdown('emails.send.invoice', ['data', $this->data]); | ||||||
|  |  | ||||||
|         if ($this->data['attach']['data']) { |         if ($this->data['attach']['data']) { | ||||||
|             $mailContent->attachData( |             $mailContent->attachData( | ||||||
|  | |||||||
| @ -34,7 +34,7 @@ class SendPaymentMail extends Mailable | |||||||
|     public function build() |     public function build() | ||||||
|     { |     { | ||||||
|         $log = EmailLog::create([ |         $log = EmailLog::create([ | ||||||
|             'from' => $this->data['from_address'], |             'from' => $this->data['from'], | ||||||
|             'to' => $this->data['to'], |             'to' => $this->data['to'], | ||||||
|             'subject' => $this->data['subject'], |             'subject' => $this->data['subject'], | ||||||
|             'body' => $this->data['body'], |             'body' => $this->data['body'], | ||||||
| @ -47,9 +47,9 @@ class SendPaymentMail extends Mailable | |||||||
|  |  | ||||||
|         $this->data['url'] = route('payment', ['email_log' => $log->token]); |         $this->data['url'] = route('payment', ['email_log' => $log->token]); | ||||||
|  |  | ||||||
|         $mailContent = $this->from($this->data['from_address'], $this->data['from_name']) |         $mailContent = $this->from($this->data['from'], config('mail.from.name')) | ||||||
|             ->subject($this->data['subject']) |                     ->subject($this->data['subject']) | ||||||
|             ->markdown("emails.send.payment", ['data', $this->data]); |                     ->markdown('emails.send.payment', ['data', $this->data]); | ||||||
|  |  | ||||||
|         if ($this->data['attach']['data']) { |         if ($this->data['attach']['data']) { | ||||||
|             $mailContent->attachData( |             $mailContent->attachData( | ||||||
|  | |||||||
| @ -217,7 +217,7 @@ class Company extends Model implements HasMedia | |||||||
|             'estimate_billing_address_format' => $billingAddressFormat, |             'estimate_billing_address_format' => $billingAddressFormat, | ||||||
|             'payment_company_address_format' => $companyAddressFormat, |             'payment_company_address_format' => $companyAddressFormat, | ||||||
|             'payment_from_customer_address_format' => $paymentFromCustomerAddress, |             'payment_from_customer_address_format' => $paymentFromCustomerAddress, | ||||||
|             'currency' => request()->currency ?? 13, |             'currency' => request()->currency ?? 1, | ||||||
|             'time_zone' => 'Asia/Kolkata', |             'time_zone' => 'Asia/Kolkata', | ||||||
|             'language' => 'en', |             'language' => 'en', | ||||||
|             'fiscal_year' => '1-12', |             'fiscal_year' => '1-12', | ||||||
|  | |||||||
| @ -5,10 +5,10 @@ namespace Crater\Models; | |||||||
| use App; | use App; | ||||||
| use Barryvdh\DomPDF\Facade as PDF; | use Barryvdh\DomPDF\Facade as PDF; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
|  | use Crater\Mail\SendEstimateMail; | ||||||
| use Crater\Services\SerialNumberFormatter; | use Crater\Services\SerialNumberFormatter; | ||||||
| use Crater\Traits\GeneratesPdfTrait; | use Crater\Traits\GeneratesPdfTrait; | ||||||
| use Crater\Traits\HasCustomFieldsTrait; | use Crater\Traits\HasCustomFieldsTrait; | ||||||
| use Crater\Traits\MailTrait; |  | ||||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||||
| use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||||
| use Illuminate\Support\Facades\Storage; | use Illuminate\Support\Facades\Storage; | ||||||
| @ -20,7 +20,6 @@ use Vinkla\Hashids\Facades\Hashids; | |||||||
| class Estimate extends Model implements HasMedia | class Estimate extends Model implements HasMedia | ||||||
| { | { | ||||||
|     use HasFactory; |     use HasFactory; | ||||||
|     use MailTrait; |  | ||||||
|     use InteractsWithMedia; |     use InteractsWithMedia; | ||||||
|     use GeneratesPdfTrait; |     use GeneratesPdfTrait; | ||||||
|     use HasCustomFieldsTrait; |     use HasCustomFieldsTrait; | ||||||
| @ -364,7 +363,7 @@ class Estimate extends Model implements HasMedia | |||||||
|             $this->save(); |             $this->save(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $this->setMail('estimate', $data); |         \Mail::to($data['to'])->send(new SendEstimateMail($data)); | ||||||
|  |  | ||||||
|         return [ |         return [ | ||||||
|             'success' => true, |             'success' => true, | ||||||
| @ -484,7 +483,8 @@ class Estimate extends Model implements HasMedia | |||||||
|             '{ESTIMATE_DATE}' => $this->formattedEstimateDate, |             '{ESTIMATE_DATE}' => $this->formattedEstimateDate, | ||||||
|             '{ESTIMATE_EXPIRY_DATE}' => $this->formattedExpiryDate, |             '{ESTIMATE_EXPIRY_DATE}' => $this->formattedExpiryDate, | ||||||
|             '{ESTIMATE_NUMBER}' => $this->estimate_number, |             '{ESTIMATE_NUMBER}' => $this->estimate_number, | ||||||
|             '{ESTIMATE_REF_NUMBER}' => $this->reference_number, |             '{PDF_LINK}' => $this->estimatePdfUrl, | ||||||
|  |             '{TOTAL_AMOUNT}' => format_money_pdf($this->total, $this->customer->currency) | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -240,7 +240,7 @@ class Expense extends Model implements HasMedia | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($request->hasFile('attachment_receipt')) { |         if ($request->hasFile('attachment_receipt')) { | ||||||
|             $expense->addMediaFromRequest('attachment_receipt')->toMediaCollection('receipts'); |             $expense->addMediaFromRequest('attachment_receipt')->toMediaCollection('receipts', 'local'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($request->customFields) { |         if ($request->customFields) { | ||||||
| @ -262,12 +262,12 @@ class Expense extends Model implements HasMedia | |||||||
|             ExchangeRateLog::addExchangeRateLog($this); |             ExchangeRateLog::addExchangeRateLog($this); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (isset($request->is_attachment_receipt_removed) && (bool) $request->is_attachment_receipt_removed) { |         if (isset($request->is_attachment_receipt_removed) && $request->is_attachment_receipt_removed == "true") { | ||||||
|             $this->clearMediaCollection('receipts'); |             $this->clearMediaCollection('receipts'); | ||||||
|         } |         } | ||||||
|         if ($request->hasFile('attachment_receipt')) { |         if ($request->hasFile('attachment_receipt')) { | ||||||
|             $this->clearMediaCollection('receipts'); |             $this->clearMediaCollection('receipts'); | ||||||
|             $this->addMediaFromRequest('attachment_receipt')->toMediaCollection('receipts'); |             $this->addMediaFromRequest('attachment_receipt')->toMediaCollection('receipts', 'local'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($request->customFields) { |         if ($request->customFields) { | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ use Crater\Mail\SendInvoiceMail; | |||||||
| use Crater\Services\SerialNumberFormatter; | use Crater\Services\SerialNumberFormatter; | ||||||
| use Crater\Traits\GeneratesPdfTrait; | use Crater\Traits\GeneratesPdfTrait; | ||||||
| use Crater\Traits\HasCustomFieldsTrait; | use Crater\Traits\HasCustomFieldsTrait; | ||||||
| use Crater\Traits\MailTrait; |  | ||||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||||
| use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||||
| use Illuminate\Support\Facades\Storage; | use Illuminate\Support\Facades\Storage; | ||||||
| @ -22,7 +21,6 @@ use Vinkla\Hashids\Facades\Hashids; | |||||||
| class Invoice extends Model implements HasMedia | class Invoice extends Model implements HasMedia | ||||||
| { | { | ||||||
|     use HasFactory; |     use HasFactory; | ||||||
|     use MailTrait; |  | ||||||
|     use InteractsWithMedia; |     use InteractsWithMedia; | ||||||
|     use GeneratesPdfTrait; |     use GeneratesPdfTrait; | ||||||
|     use HasCustomFieldsTrait; |     use HasCustomFieldsTrait; | ||||||
| @ -189,16 +187,6 @@ class Invoice extends Model implements HasMedia | |||||||
|         return Carbon::parse($this->invoice_date)->format($dateFormat); |         return Carbon::parse($this->invoice_date)->format($dateFormat); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function scopeWhereStatus($query, $status) |  | ||||||
|     { |  | ||||||
|         return $query->where('invoices.status', $status); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function scopeWherePaidStatus($query, $status) |  | ||||||
|     { |  | ||||||
|         return $query->where('invoices.paid_status', $status); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function scopeWhereDueStatus($query, $status) |     public function scopeWhereDueStatus($query, $status) | ||||||
|     { |     { | ||||||
|         return $query->whereIn('invoices.paid_status', [ |         return $query->whereIn('invoices.paid_status', [ | ||||||
| @ -236,6 +224,40 @@ class Invoice extends Model implements HasMedia | |||||||
|         $query->orderBy($orderByField, $orderBy); |         $query->orderBy($orderByField, $orderBy); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public function scopeWhereStatus($query, $status) | ||||||
|  |     { | ||||||
|  |         return $query->where('invoices.status', $status); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function scopeWherePaidStatus($query, $status) | ||||||
|  |     { | ||||||
|  |         return $query->where('invoices.paid_status', $status); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function scopeWhereTabFilters($query, $status) | ||||||
|  |     { | ||||||
|  |         if ($status == "DRAFT") { | ||||||
|  |             return $query->where('invoices.status', $status); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if ($status == "SENT") { | ||||||
|  |             return $query->whereIn('invoices.status', [ | ||||||
|  |                 self::STATUS_SENT, | ||||||
|  |                 self::STATUS_VIEWED, | ||||||
|  |                 self::STATUS_COMPLETED | ||||||
|  |             ]); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         if ($status == 'DUE') { | ||||||
|  |             return $query->whereIn('invoices.paid_status', [ | ||||||
|  |                 self::STATUS_UNPAID, | ||||||
|  |                 self::STATUS_PARTIALLY_PAID, | ||||||
|  |             ]); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return ; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public function scopeApplyFilters($query, array $filters) |     public function scopeApplyFilters($query, array $filters) | ||||||
|     { |     { | ||||||
|         $filters = collect($filters); |         $filters = collect($filters); | ||||||
| @ -251,17 +273,11 @@ class Invoice extends Model implements HasMedia | |||||||
|                 $filters->get('status') == self::STATUS_PAID |                 $filters->get('status') == self::STATUS_PAID | ||||||
|             ) { |             ) { | ||||||
|                 $query->wherePaidStatus($filters->get('status')); |                 $query->wherePaidStatus($filters->get('status')); | ||||||
|             } elseif ($filters->get('status') == 'DUE') { |  | ||||||
|                 $query->whereDueStatus($filters->get('status')); |  | ||||||
|             } else { |             } else { | ||||||
|                 $query->whereStatus($filters->get('status')); |                 $query->whereStatus($filters->get('status')); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if ($filters->get('paid_status')) { |  | ||||||
|             $query->wherePaidStatus($filters->get('status')); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if ($filters->get('invoice_id')) { |         if ($filters->get('invoice_id')) { | ||||||
|             $query->whereInvoice($filters->get('invoice_id')); |             $query->whereInvoice($filters->get('invoice_id')); | ||||||
|         } |         } | ||||||
| @ -466,7 +482,7 @@ class Invoice extends Model implements HasMedia | |||||||
|     { |     { | ||||||
|         $data = $this->sendInvoiceData($data); |         $data = $this->sendInvoiceData($data); | ||||||
|  |  | ||||||
|         $this->setMail('invoice', $data); |         \Mail::to($data['to'])->send(new SendInvoiceMail($data)); | ||||||
|  |  | ||||||
|         if ($this->status == Invoice::STATUS_DRAFT) { |         if ($this->status == Invoice::STATUS_DRAFT) { | ||||||
|             $this->status = Invoice::STATUS_SENT; |             $this->status = Invoice::STATUS_SENT; | ||||||
| @ -653,7 +669,9 @@ class Invoice extends Model implements HasMedia | |||||||
|             '{INVOICE_DATE}' => $this->formattedInvoiceDate, |             '{INVOICE_DATE}' => $this->formattedInvoiceDate, | ||||||
|             '{INVOICE_DUE_DATE}' => $this->formattedDueDate, |             '{INVOICE_DUE_DATE}' => $this->formattedDueDate, | ||||||
|             '{INVOICE_NUMBER}' => $this->invoice_number, |             '{INVOICE_NUMBER}' => $this->invoice_number, | ||||||
|             '{INVOICE_REF_NUMBER}' => $this->reference_number, |             '{PDF_LINK}' => $this->invoicePdfUrl, | ||||||
|  |             '{DUE_AMOUNT}' => format_money_pdf($this->due_amount, $this->customer->currency), | ||||||
|  |             '{TOTAL_AMOUNT}' => format_money_pdf($this->total, $this->customer->currency) | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,111 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Models; |  | ||||||
|  |  | ||||||
| use Crater\Http\Requests\MailSenderRequest; |  | ||||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; |  | ||||||
| use Illuminate\Database\Eloquent\Model; |  | ||||||
| use Config; |  | ||||||
|  |  | ||||||
| class MailSender extends Model |  | ||||||
| { |  | ||||||
|     use HasFactory; |  | ||||||
|  |  | ||||||
|     protected $guarded = [ |  | ||||||
|         'id' |  | ||||||
|     ]; |  | ||||||
|  |  | ||||||
|     protected $casts = [ |  | ||||||
|         'settings' => 'array', |  | ||||||
|         'is_default' => 'boolean' |  | ||||||
|     ]; |  | ||||||
|  |  | ||||||
|     public function company() |  | ||||||
|     { |  | ||||||
|         return $this->belongsTo(Company::class); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function scopeWhereOrder($query, $orderByField, $orderBy) |  | ||||||
|     { |  | ||||||
|         $query->orderBy($orderByField, $orderBy); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function scopeApplyFilters($query, array $filters) |  | ||||||
|     { |  | ||||||
|         $filters = collect($filters); |  | ||||||
|  |  | ||||||
|         if ($filters->get('orderByField') || $filters->get('orderBy')) { |  | ||||||
|             $field = $filters->get('orderByField') ? $filters->get('orderByField') : 'name'; |  | ||||||
|             $orderBy = $filters->get('orderBy') ? $filters->get('orderBy') : 'desc'; |  | ||||||
|             $query->whereOrder($field, $orderBy); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function scopePaginateData($query, $limit) |  | ||||||
|     { |  | ||||||
|         if ($limit == 'all') { |  | ||||||
|             return $query->get(); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return $query->paginate($limit); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function scopeWhereCompany($query) |  | ||||||
|     { |  | ||||||
|         $query->where('mail_senders.company_id', request()->header('company')); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static function createFromRequest(MailSenderRequest $request) |  | ||||||
|     { |  | ||||||
|         $senderMail = self::create($request->getMailSenderPayload()); |  | ||||||
|  |  | ||||||
|         if ($request->is_default) { |  | ||||||
|             $senderMail->removeOtherDefaultMailSenders($request); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return $senderMail; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function updateFromRequest(MailSenderRequest $request) |  | ||||||
|     { |  | ||||||
|         $data = $request->getMailSenderPayload(); |  | ||||||
|  |  | ||||||
|         $this->update($data); |  | ||||||
|  |  | ||||||
|         if ($request->is_default) { |  | ||||||
|             $this->removeOtherDefaultMailSenders($request); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return $this; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static function setMailConfiguration($id, $check = null) |  | ||||||
|     { |  | ||||||
|         $mailSender = MailSender::find($id); |  | ||||||
|  |  | ||||||
|         $settings = $mailSender->settings; |  | ||||||
|         $settings['driver'] = $mailSender->driver; |  | ||||||
|         $settings['from'] = [ |  | ||||||
|             'address' => $mailSender->from_address, |  | ||||||
|             'name' => $mailSender->from_name |  | ||||||
|         ]; |  | ||||||
|         $settings['sendmail'] = config('mail.sendmail'); |  | ||||||
|         $settings['markdown'] = config('mail.markdown'); |  | ||||||
|         $settings['log_channel'] = config('mail.log_channel'); |  | ||||||
|  |  | ||||||
|         Config::set('mail', $settings); |  | ||||||
|  |  | ||||||
|         if ($check) { |  | ||||||
|             return $mailSender; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function removeOtherDefaultMailSenders($request) { |  | ||||||
|         MailSender::where('company_id', $request->header('company')) |  | ||||||
|             ->where('is_default', true) |  | ||||||
|             ->where('id', '<>', $this->id) |  | ||||||
|             ->update(['is_default' => false]); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -5,10 +5,10 @@ namespace Crater\Models; | |||||||
| use Barryvdh\DomPDF\Facade as PDF; | use Barryvdh\DomPDF\Facade as PDF; | ||||||
| use Carbon\Carbon; | use Carbon\Carbon; | ||||||
| use Crater\Jobs\GeneratePaymentPdfJob; | use Crater\Jobs\GeneratePaymentPdfJob; | ||||||
|  | use Crater\Mail\SendPaymentMail; | ||||||
| use Crater\Services\SerialNumberFormatter; | use Crater\Services\SerialNumberFormatter; | ||||||
| use Crater\Traits\GeneratesPdfTrait; | use Crater\Traits\GeneratesPdfTrait; | ||||||
| use Crater\Traits\HasCustomFieldsTrait; | use Crater\Traits\HasCustomFieldsTrait; | ||||||
| use Crater\Traits\MailTrait; |  | ||||||
| use Illuminate\Database\Eloquent\Factories\HasFactory; | use Illuminate\Database\Eloquent\Factories\HasFactory; | ||||||
| use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||||
| use Spatie\MediaLibrary\HasMedia; | use Spatie\MediaLibrary\HasMedia; | ||||||
| @ -18,7 +18,6 @@ use Vinkla\Hashids\Facades\Hashids; | |||||||
| class Payment extends Model implements HasMedia | class Payment extends Model implements HasMedia | ||||||
| { | { | ||||||
|     use HasFactory; |     use HasFactory; | ||||||
|     use MailTrait; |  | ||||||
|     use InteractsWithMedia; |     use InteractsWithMedia; | ||||||
|     use GeneratesPdfTrait; |     use GeneratesPdfTrait; | ||||||
|     use HasCustomFieldsTrait; |     use HasCustomFieldsTrait; | ||||||
| @ -136,7 +135,7 @@ class Payment extends Model implements HasMedia | |||||||
|     { |     { | ||||||
|         $data = $this->sendPaymentData($data); |         $data = $this->sendPaymentData($data); | ||||||
|  |  | ||||||
|         $this->setMail('payment', $data); |         \Mail::to($data['to'])->send(new SendPaymentMail($data)); | ||||||
|  |  | ||||||
|         return [ |         return [ | ||||||
|             'success' => true, |             'success' => true, | ||||||
| @ -436,7 +435,8 @@ class Payment extends Model implements HasMedia | |||||||
|             '{PAYMENT_DATE}' => $this->formattedPaymentDate, |             '{PAYMENT_DATE}' => $this->formattedPaymentDate, | ||||||
|             '{PAYMENT_MODE}' => $this->paymentMethod ? $this->paymentMethod->name : null, |             '{PAYMENT_MODE}' => $this->paymentMethod ? $this->paymentMethod->name : null, | ||||||
|             '{PAYMENT_NUMBER}' => $this->payment_number, |             '{PAYMENT_NUMBER}' => $this->payment_number, | ||||||
|             '{PAYMENT_AMOUNT}' => $this->reference_number, |             '{PDF_LINK}' => $this->paymentPdfUrl, | ||||||
|  |             '{PAYMENT_AMOUNT}' => format_money_pdf($this->amount, $this->customer->currency) | ||||||
|         ]; |         ]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,123 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Policies; |  | ||||||
|  |  | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Crater\Models\User; |  | ||||||
| use Illuminate\Auth\Access\HandlesAuthorization; |  | ||||||
| use Silber\Bouncer\BouncerFacade; |  | ||||||
|  |  | ||||||
| class MailSenderPolicy |  | ||||||
| { |  | ||||||
|     use HandlesAuthorization; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can view any models. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function viewAny(User $user) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('view-mail-sender', MailSender::class)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can view the model. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @param  \Crater\Models\MailSender  $mailSender |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function view(User $user, MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('view-mail-sender', $mailSender) && $user->hasCompany($mailSender->company_id)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can create models. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function create(User $user) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('create-mail-sender', MailSender::class)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can update the model. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @param  \Crater\Models\MailSender  $mailSender |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function update(User $user, MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('edit-mail-sender', $mailSender) && $user->hasCompany($mailSender->company_id)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can delete the model. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @param  \Crater\Models\MailSender  $mailSender |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function delete(User $user, MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('delete-mail-sender', $mailSender) && $user->hasCompany($mailSender->company_id)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can restore the model. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @param  \Crater\Models\MailSender  $mailSender |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function restore(User $user, MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('delete-mail-sender', $mailSender) && $user->hasCompany($mailSender->company_id)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Determine whether the user can permanently delete the model. |  | ||||||
|      * |  | ||||||
|      * @param  \Crater\Models\User  $user |  | ||||||
|      * @param  \Crater\Models\MailSender  $mailSender |  | ||||||
|      * @return \Illuminate\Auth\Access\Response|bool |  | ||||||
|      */ |  | ||||||
|     public function forceDelete(User $user, MailSender $mailSender) |  | ||||||
|     { |  | ||||||
|         if (BouncerFacade::can('delete-mail-sender', $mailSender) && $user->hasCompany($mailSender->company_id)) { |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return false; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -39,7 +39,6 @@ class AuthServiceProvider extends ServiceProvider | |||||||
|         \Crater\Models\CustomField::class => \Crater\Policies\CustomFieldPolicy::class, |         \Crater\Models\CustomField::class => \Crater\Policies\CustomFieldPolicy::class, | ||||||
|         \Crater\Models\User::class => \Crater\Policies\UserPolicy::class, |         \Crater\Models\User::class => \Crater\Policies\UserPolicy::class, | ||||||
|         \Crater\Models\Item::class => \Crater\Policies\ItemPolicy::class, |         \Crater\Models\Item::class => \Crater\Policies\ItemPolicy::class, | ||||||
|         \Crater\Models\MailSender::class => \Crater\Policies\MailSenderPolicy::class, |  | ||||||
|         \Silber\Bouncer\Database\Role::class => \Crater\Policies\RolePolicy::class, |         \Silber\Bouncer\Database\Role::class => \Crater\Policies\RolePolicy::class, | ||||||
|         \Crater\Models\Unit::class => \Crater\Policies\UnitPolicy::class, |         \Crater\Models\Unit::class => \Crater\Policies\UnitPolicy::class, | ||||||
|         \Crater\Models\RecurringInvoice::class => \Crater\Policies\RecurringInvoicePolicy::class, |         \Crater\Models\RecurringInvoice::class => \Crater\Policies\RecurringInvoicePolicy::class, | ||||||
|  | |||||||
| @ -223,6 +223,204 @@ class EnvironmentManager | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |     * Save the mail content to the .env file. | ||||||
|  |     * | ||||||
|  |     * @param Request $request | ||||||
|  |     * @return array | ||||||
|  |     */ | ||||||
|  |     public function saveMailVariables(MailEnvironmentRequest $request) | ||||||
|  |     { | ||||||
|  |         $mailData = $this->getMailData($request); | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             file_put_contents($this->envPath, str_replace( | ||||||
|  |                 $mailData['old_mail_data'], | ||||||
|  |                 $mailData['new_mail_data'], | ||||||
|  |                 file_get_contents($this->envPath) | ||||||
|  |             )); | ||||||
|  |  | ||||||
|  |             if ($mailData['extra_old_mail_data']) { | ||||||
|  |                 file_put_contents($this->envPath, str_replace( | ||||||
|  |                     $mailData['extra_old_mail_data'], | ||||||
|  |                     $mailData['extra_mail_data'], | ||||||
|  |                     file_get_contents($this->envPath) | ||||||
|  |                 )); | ||||||
|  |             } else { | ||||||
|  |                 file_put_contents( | ||||||
|  |                     $this->envPath, | ||||||
|  |                     "\n".$mailData['extra_mail_data'], | ||||||
|  |                     FILE_APPEND | ||||||
|  |                 ); | ||||||
|  |             } | ||||||
|  |         } catch (Exception $e) { | ||||||
|  |             return [ | ||||||
|  |                 'error' => 'mail_variables_save_error', | ||||||
|  |             ]; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return [ | ||||||
|  |             'success' => 'mail_variables_save_successfully', | ||||||
|  |         ]; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private function getMailData($request) | ||||||
|  |     { | ||||||
|  |         $mailFromCredential = ""; | ||||||
|  |         $extraMailData = ""; | ||||||
|  |         $extraOldMailData = ""; | ||||||
|  |         $oldMailData = ""; | ||||||
|  |         $newMailData = ""; | ||||||
|  |  | ||||||
|  |         if (env('MAIL_FROM_ADDRESS') !== null && env('MAIL_FROM_NAME') !== null) { | ||||||
|  |             $mailFromCredential = | ||||||
|  |                 'MAIL_FROM_ADDRESS='.config('mail.from.address')."\n". | ||||||
|  |                 'MAIL_FROM_NAME="'.config('mail.from.name')."\"\n\n"; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         switch ($request->mail_driver) { | ||||||
|  |             case 'smtp': | ||||||
|  |  | ||||||
|  |                 $oldMailData = | ||||||
|  |                     'MAIL_DRIVER='.config('mail.driver')."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     $mailFromCredential; | ||||||
|  |  | ||||||
|  |                 $newMailData = | ||||||
|  |                     'MAIL_DRIVER='.$request->mail_driver."\n". | ||||||
|  |                     'MAIL_HOST='.$request->mail_host."\n". | ||||||
|  |                     'MAIL_PORT='.$request->mail_port."\n". | ||||||
|  |                     'MAIL_USERNAME='.$request->mail_username."\n". | ||||||
|  |                     'MAIL_PASSWORD='.$request->mail_password."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n". | ||||||
|  |                     'MAIL_FROM_ADDRESS='.$request->from_mail."\n". | ||||||
|  |                     'MAIL_FROM_NAME="'.$request->from_name."\"\n\n"; | ||||||
|  |  | ||||||
|  |                 break; | ||||||
|  |  | ||||||
|  |             case 'mailgun': | ||||||
|  |                 $oldMailData = | ||||||
|  |                     'MAIL_DRIVER='.config('mail.driver')."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     $mailFromCredential; | ||||||
|  |  | ||||||
|  |                 $newMailData = | ||||||
|  |                     'MAIL_DRIVER='.$request->mail_driver."\n". | ||||||
|  |                     'MAIL_HOST='.$request->mail_host."\n". | ||||||
|  |                     'MAIL_PORT='.$request->mail_port."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n". | ||||||
|  |                     'MAIL_FROM_ADDRESS='.$request->from_mail."\n". | ||||||
|  |                     'MAIL_FROM_NAME="'.$request->from_name."\"\n\n"; | ||||||
|  |  | ||||||
|  |                 $extraMailData = | ||||||
|  |                     'MAILGUN_DOMAIN='.$request->mail_mailgun_domain."\n". | ||||||
|  |                     'MAILGUN_SECRET='.$request->mail_mailgun_secret."\n". | ||||||
|  |                     'MAILGUN_ENDPOINT='.$request->mail_mailgun_endpoint."\n"; | ||||||
|  |  | ||||||
|  |                 if (env('MAILGUN_DOMAIN') !== null && env('MAILGUN_SECRET') !== null && env('MAILGUN_ENDPOINT') !== null) { | ||||||
|  |                     $extraOldMailData = | ||||||
|  |                         'MAILGUN_DOMAIN='.config('services.mailgun.domain')."\n". | ||||||
|  |                         'MAILGUN_SECRET='.config('services.mailgun.secret')."\n". | ||||||
|  |                         'MAILGUN_ENDPOINT='.config('services.mailgun.endpoint')."\n"; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 break; | ||||||
|  |  | ||||||
|  |             case 'ses': | ||||||
|  |                 $oldMailData = | ||||||
|  |                     'MAIL_DRIVER='.config('mail.driver')."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     $mailFromCredential; | ||||||
|  |  | ||||||
|  |                 $newMailData = | ||||||
|  |                     'MAIL_DRIVER='.$request->mail_driver."\n". | ||||||
|  |                     'MAIL_HOST='.$request->mail_host."\n". | ||||||
|  |                     'MAIL_PORT='.$request->mail_port."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.$request->mail_encryption."\n\n". | ||||||
|  |                     'MAIL_FROM_ADDRESS='.$request->from_mail."\n". | ||||||
|  |                     'MAIL_FROM_NAME="'.$request->from_name."\"\n\n"; | ||||||
|  |  | ||||||
|  |                 $extraMailData = | ||||||
|  |                     'SES_KEY='.$request->mail_ses_key."\n". | ||||||
|  |                     'SES_SECRET='.$request->mail_ses_secret."\n"; | ||||||
|  |  | ||||||
|  |                 if (env('SES_KEY') !== null && env('SES_SECRET') !== null) { | ||||||
|  |                     $extraOldMailData = | ||||||
|  |                         'SES_KEY='.config('services.ses.key')."\n". | ||||||
|  |                         'SES_SECRET='.config('services.ses.secret')."\n"; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 break; | ||||||
|  |  | ||||||
|  |             case 'mail': | ||||||
|  |                 $oldMailData = | ||||||
|  |                     'MAIL_DRIVER='.config('mail.driver')."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     $mailFromCredential; | ||||||
|  |  | ||||||
|  |                 $newMailData = | ||||||
|  |                     'MAIL_DRIVER='.$request->mail_driver."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     'MAIL_FROM_ADDRESS='.$request->from_mail."\n". | ||||||
|  |                     'MAIL_FROM_NAME="'.$request->from_name."\"\n\n"; | ||||||
|  |  | ||||||
|  |                 break; | ||||||
|  |  | ||||||
|  |             case 'sendmail': | ||||||
|  |                 $oldMailData = | ||||||
|  |                     'MAIL_DRIVER='.config('mail.driver')."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     $mailFromCredential; | ||||||
|  |  | ||||||
|  |                 $newMailData = | ||||||
|  |                     'MAIL_DRIVER='.$request->mail_driver."\n". | ||||||
|  |                     'MAIL_HOST='.config('mail.host')."\n". | ||||||
|  |                     'MAIL_PORT='.config('mail.port')."\n". | ||||||
|  |                     'MAIL_USERNAME='.config('mail.username')."\n". | ||||||
|  |                     'MAIL_PASSWORD='.config('mail.password')."\n". | ||||||
|  |                     'MAIL_ENCRYPTION='.config('mail.encryption')."\n\n". | ||||||
|  |                     'MAIL_FROM_ADDRESS='.$request->from_mail."\n". | ||||||
|  |                     'MAIL_FROM_NAME="'.$request->from_name."\"\n\n"; | ||||||
|  |  | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return [ | ||||||
|  |             'old_mail_data' => $oldMailData, | ||||||
|  |             'new_mail_data' => $newMailData, | ||||||
|  |             'extra_mail_data' => $extraMailData, | ||||||
|  |             'extra_old_mail_data' => $extraOldMailData, | ||||||
|  |         ]; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Save the disk content to the .env file. |      * Save the disk content to the .env file. | ||||||
|      * |      * | ||||||
|  | |||||||
| @ -5,7 +5,6 @@ use Crater\Models\Currency; | |||||||
| use Crater\Models\CustomField; | use Crater\Models\CustomField; | ||||||
| use Crater\Models\Setting; | use Crater\Models\Setting; | ||||||
| use Illuminate\Support\Str; | use Illuminate\Support\Str; | ||||||
| use Illuminate\Mail\Mailable; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Get company setting |  * Get company setting | ||||||
| @ -71,42 +70,6 @@ function set_active($path, $active = 'active') | |||||||
|     return call_user_func_array('Request::is', (array)$path) ? $active : ''; |     return call_user_func_array('Request::is', (array)$path) ? $active : ''; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Send Mail |  | ||||||
|  * |  | ||||||
|  * @param Mailable $mailable |  | ||||||
|  * @param object $mailSender |  | ||||||
|  * @return string $to |  | ||||||
|  */ |  | ||||||
| function send_mail(Mailable $mailable, object $mailSender = null, string $to) |  | ||||||
| { |  | ||||||
|     if ($mailSender->bcc && $mailSender->cc) { |  | ||||||
|         \Mail::to($to) |  | ||||||
|                 ->bcc(explode(',', $mailSender->bcc)) |  | ||||||
|                 ->cc(explode(',', $mailSender->cc)) |  | ||||||
|                 ->send($mailable); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if ($mailSender->bcc && $mailSender->cc == null) { |  | ||||||
|         \Mail::to($to) |  | ||||||
|             ->bcc(explode(',', $mailSender->bcc)) |  | ||||||
|             ->send($mailable); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if ($mailSender->bcc == null && $mailSender->cc) { |  | ||||||
|         \Mail::to($to) |  | ||||||
|             ->cc(explode(',', $mailSender->cc)) |  | ||||||
|             ->send($mailable); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if ($mailSender->bcc == null && $mailSender->cc == null) { |  | ||||||
|         \Mail::to($to) |  | ||||||
|             ->send($mailable); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     return true; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @param $path |  * @param $path | ||||||
|  * @return mixed |  * @return mixed | ||||||
|  | |||||||
| @ -1,40 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| namespace Crater\Traits; |  | ||||||
|  |  | ||||||
| use Crater\Mail\EstimateViewedMail; |  | ||||||
| use Crater\Mail\InvoiceViewedMail; |  | ||||||
| use Crater\Mail\SendEstimateMail; |  | ||||||
| use Crater\Mail\SendInvoiceMail; |  | ||||||
| use Crater\Mail\SendPaymentMail; |  | ||||||
| use Crater\Models\MailSender; |  | ||||||
|  |  | ||||||
| trait MailTrait |  | ||||||
| { |  | ||||||
|     public function setMail($model, $data) |  | ||||||
|     { |  | ||||||
|         $mailSender = MailSender::setMailConfiguration($data['mail_sender_id'], true); |  | ||||||
|  |  | ||||||
|         $data['from_address'] = $mailSender->from_address; |  | ||||||
|         $data['from_name'] = $mailSender->from_name; |  | ||||||
|  |  | ||||||
|         switch ($model) { |  | ||||||
|             case 'invoice': |  | ||||||
|                send_mail(new SendInvoiceMail($data), $mailSender, $data['to']); |  | ||||||
|  |  | ||||||
|                 break; |  | ||||||
|  |  | ||||||
|             case 'estimate': |  | ||||||
|                send_mail(new SendEstimateMail($data), $mailSender, $data['to']); |  | ||||||
|  |  | ||||||
|                 break; |  | ||||||
|  |  | ||||||
|             case 'payment': |  | ||||||
|                send_mail(new SendPaymentMail($data), $mailSender, $data['to']); |  | ||||||
|  |  | ||||||
|                 break; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -7,7 +7,6 @@ use Crater\Models\ExchangeRateProvider; | |||||||
| use Crater\Models\Expense; | use Crater\Models\Expense; | ||||||
| use Crater\Models\Invoice; | use Crater\Models\Invoice; | ||||||
| use Crater\Models\Item; | use Crater\Models\Item; | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Crater\Models\Note; | use Crater\Models\Note; | ||||||
| use Crater\Models\Payment; | use Crater\Models\Payment; | ||||||
| use Crater\Models\RecurringInvoice; | use Crater\Models\RecurringInvoice; | ||||||
| @ -398,41 +397,6 @@ return [ | |||||||
|             ] |             ] | ||||||
|         ], |         ], | ||||||
|  |  | ||||||
|         // Mail Sender |  | ||||||
|         [ |  | ||||||
|             "name" => "view mail sender", |  | ||||||
|             "ability" => "view-mail-sender", |  | ||||||
|             "model" => MailSender::class, |  | ||||||
|             'owner_only' => false, |  | ||||||
|         ], |  | ||||||
|         [ |  | ||||||
|             "name" => "create mail sender", |  | ||||||
|             "ability" => "create-mail-sender", |  | ||||||
|             "model" => MailSender::class, |  | ||||||
|             'owner_only' => false, |  | ||||||
|             "depends_on" => [ |  | ||||||
|                 'view-mail-sender', |  | ||||||
|             ] |  | ||||||
|         ], |  | ||||||
|         [ |  | ||||||
|             "name" => "edit mail sender", |  | ||||||
|             "ability" => "edit-mail-sender", |  | ||||||
|             "model" => MailSender::class, |  | ||||||
|             'owner_only' => false, |  | ||||||
|             "depends_on" => [ |  | ||||||
|                 'view-mail-sender', |  | ||||||
|             ] |  | ||||||
|         ], |  | ||||||
|         [ |  | ||||||
|             "name" => "delete mail sender", |  | ||||||
|             "ability" => "delete-mail-sender", |  | ||||||
|             "model" => MailSender::class, |  | ||||||
|             'owner_only' => false, |  | ||||||
|             "depends_on" => [ |  | ||||||
|                 'view-mail-sender', |  | ||||||
|             ] |  | ||||||
|         ], |  | ||||||
|  |  | ||||||
|         // Settings |         // Settings | ||||||
|         [ |         [ | ||||||
|             "name" => "view company dashboard", |             "name" => "view company dashboard", | ||||||
|  | |||||||
| @ -7,7 +7,6 @@ use Crater\Models\ExchangeRateProvider; | |||||||
| use Crater\Models\Expense; | use Crater\Models\Expense; | ||||||
| use Crater\Models\Invoice; | use Crater\Models\Invoice; | ||||||
| use Crater\Models\Item; | use Crater\Models\Item; | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Crater\Models\Note; | use Crater\Models\Note; | ||||||
| use Crater\Models\Payment; | use Crater\Models\Payment; | ||||||
| use Crater\Models\RecurringInvoice; | use Crater\Models\RecurringInvoice; | ||||||
| @ -226,17 +225,6 @@ return [ | |||||||
|             'ability' => 'view-all-notes', |             'ability' => 'view-all-notes', | ||||||
|             'model' => Note::class |             'model' => Note::class | ||||||
|         ], |         ], | ||||||
|         [ |  | ||||||
|             'title' => 'settings.menu_title.mail_sender', |  | ||||||
|             'group' => '', |  | ||||||
|             'name' => 'Mail Sender', |  | ||||||
|             'link' => '/admin/settings/mail-sender', |  | ||||||
|             'icon' => 'MailIcon', |  | ||||||
|             'owner_only' => false, |  | ||||||
|             'ability' => 'view-mail-sender', |  | ||||||
|             'model' => MailSender::class |  | ||||||
|         ], |  | ||||||
|  |  | ||||||
|         [ |         [ | ||||||
|             'title' => 'settings.menu_title.expense_category', |             'title' => 'settings.menu_title.expense_category', | ||||||
|             'group' => '', |             'group' => '', | ||||||
| @ -247,6 +235,16 @@ return [ | |||||||
|             'ability' => 'view-expense', |             'ability' => 'view-expense', | ||||||
|             'model' => Expense::class |             'model' => Expense::class | ||||||
|         ], |         ], | ||||||
|  |         [ | ||||||
|  |             'title' => 'settings.mail.mail_config', | ||||||
|  |             'group' => '', | ||||||
|  |             'name' => 'Mail Configuration', | ||||||
|  |             'link' => '/admin/settings/mail-configuration', | ||||||
|  |             'icon' => 'MailIcon', | ||||||
|  |             'owner_only' => true, | ||||||
|  |             'ability' => '', | ||||||
|  |             'model' => '' | ||||||
|  |         ], | ||||||
|         [ |         [ | ||||||
|             'title' => 'settings.menu_title.file_disk', |             'title' => 'settings.menu_title.file_disk', | ||||||
|             'group' => '', |             'group' => '', | ||||||
| @ -277,7 +275,6 @@ return [ | |||||||
|             'ability' => '', |             'ability' => '', | ||||||
|             'model' => '' |             'model' => '' | ||||||
|         ], |         ], | ||||||
|  |  | ||||||
|     ], |     ], | ||||||
|  |  | ||||||
|     /* |     /* | ||||||
|  | |||||||
| @ -27,7 +27,6 @@ return [ | |||||||
|             'tokenizer', |             'tokenizer', | ||||||
|             'JSON', |             'JSON', | ||||||
|             'cURL', |             'cURL', | ||||||
|             'zip', |  | ||||||
|         ], |         ], | ||||||
|         'apache' => [ |         'apache' => [ | ||||||
|             'mod_rewrite', |             'mod_rewrite', | ||||||
|  | |||||||
| @ -1,106 +0,0 @@ | |||||||
| <?php |  | ||||||
|  |  | ||||||
| use Crater\Models\Company; |  | ||||||
| use Crater\Models\MailSender; |  | ||||||
| use Crater\Models\User; |  | ||||||
| use Illuminate\Database\Migrations\Migration; |  | ||||||
| use Illuminate\Database\Schema\Blueprint; |  | ||||||
| use Illuminate\Support\Facades\Schema; |  | ||||||
| use Silber\Bouncer\BouncerFacade; |  | ||||||
|  |  | ||||||
| class CreateMailSendersTable extends Migration |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * Run the migrations. |  | ||||||
|      * |  | ||||||
|      * @return void |  | ||||||
|      */ |  | ||||||
|     public function up() |  | ||||||
|     { |  | ||||||
|         Schema::create('mail_senders', function (Blueprint $table) { |  | ||||||
|             $table->id(); |  | ||||||
|             $table->string('name'); |  | ||||||
|             $table->string('driver'); |  | ||||||
|             $table->boolean('is_default')->default(false); |  | ||||||
|             $table->string('bcc')->nullable(); |  | ||||||
|             $table->string('cc')->nullable(); |  | ||||||
|             $table->string('from_address')->nullable(); |  | ||||||
|             $table->string('from_name')->nullable(); |  | ||||||
|             $table->json('settings')->nullable(); |  | ||||||
|             $table->integer('company_id')->unsigned()->nullable(); |  | ||||||
|             $table->foreign('company_id')->references('id')->on('companies'); |  | ||||||
|             $table->timestamps(); |  | ||||||
|         }); |  | ||||||
|  |  | ||||||
|         $users = User::where('role', 'super admin')->get(); |  | ||||||
|  |  | ||||||
|         foreach ($users as $user) { |  | ||||||
|             BouncerFacade::allow($user)->toManage(MailSender::class); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         $companies = Company::all(); |  | ||||||
|  |  | ||||||
|         $companies->map(function ($company) { |  | ||||||
|             if (env('MAIL_DRIVER') == 'smtp') { |  | ||||||
|                 $settings = [ |  | ||||||
|                     'MAIL_HOST' => env('MAIL_HOST'), |  | ||||||
|                     'MAIL_PORT' => env('MAIL_PORT'), |  | ||||||
|                     'MAIL_USERNAME' => env('MAIL_USERNAME'), |  | ||||||
|                     'MAIL_PASSWORD' => env('MAIL_PASSWORD'), |  | ||||||
|                     'MAIL_ENCRYPTION' => env('MAIL_ENCRYPTION') |  | ||||||
|                 ]; |  | ||||||
|                 $this->createSender($settings, $company->id); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (env('MAIL_DRIVER') == 'mail' || env('MAIL_DRIVER') == 'sendmail') { |  | ||||||
|                 $this->createSender(null, $company->id); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (env('MAIL_DRIVER') == 'mailgun') { |  | ||||||
|                 $settings = [ |  | ||||||
|                     'MAILGUN_DOMAIN' => env('MAILGUN_DOMAIN'), |  | ||||||
|                     'MAILGUN_SECRET' => env('MAILGUN_SECRET'), |  | ||||||
|                     'MAILGUN_ENDPOINT' => env('MAILGUN_ENDPOINT'), |  | ||||||
|                 ]; |  | ||||||
|                 $this->createSender($settings, $company->id); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             if (env('MAIL_DRIVER') == 'ses') { |  | ||||||
|                 $settings = [ |  | ||||||
|                     'MAIL_HOST' => env('MAIL_HOST'), |  | ||||||
|                     'MAIL_PORT' => env('MAIL_PORT'), |  | ||||||
|                     'MAIL_ENCRYPTION' => env('MAIL_ENCRYPTION'), |  | ||||||
|                     'MAILGUN_DOMAIN' => env('MAILGUN_DOMAIN'), |  | ||||||
|                     'SES_KEY' => env('SES_KEY'), |  | ||||||
|                     'SES_SECRET' => env('SES_SECRET'), |  | ||||||
|                 ]; |  | ||||||
|                 $this->createSender($settings, $company->id); |  | ||||||
|             } |  | ||||||
|         }); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public function createSender($settings, $company_id) |  | ||||||
|     { |  | ||||||
|         $data = [ |  | ||||||
|             'name' => env('MAIL_DRIVER'), |  | ||||||
|             'driver' => env('MAIL_DRIVER'), |  | ||||||
|             'is_default' => true, |  | ||||||
|             'from_address' => env('MAIL_FROM_ADDRESS'), |  | ||||||
|             'from_name' => env('MAIL_FROM_NAME'), |  | ||||||
|             'settings' => $settings ?? null, |  | ||||||
|             'company_id' => $company_id |  | ||||||
|         ]; |  | ||||||
|  |  | ||||||
|         MailSender::create($data); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Reverse the migrations. |  | ||||||
|      * |  | ||||||
|      * @return void |  | ||||||
|      */ |  | ||||||
|     public function down() |  | ||||||
|     { |  | ||||||
|         Schema::dropIfExists('mail_senders'); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -27,7 +27,7 @@ | |||||||
|     "vite": "^2.6.1" |     "vite": "^2.6.1" | ||||||
|   }, |   }, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@headlessui/vue": "^1.4.0", |     "@headlessui/vue": "^1.5.0", | ||||||
|     "@heroicons/vue": "^1.0.1", |     "@heroicons/vue": "^1.0.1", | ||||||
|     "@popperjs/core": "^2.9.2", |     "@popperjs/core": "^2.9.2", | ||||||
|     "@stripe/stripe-js": "^1.21.2", |     "@stripe/stripe-js": "^1.21.2", | ||||||
| @ -48,7 +48,8 @@ | |||||||
|     "mini-svg-data-uri": "^1.3.3", |     "mini-svg-data-uri": "^1.3.3", | ||||||
|     "moment": "^2.29.1", |     "moment": "^2.29.1", | ||||||
|     "pinia": "^2.0.4", |     "pinia": "^2.0.4", | ||||||
|     "v-money3": "^3.13.5", |     "v-calendar": "3.0.0-alpha.8", | ||||||
|  |     "v-money3": "3.16.1", | ||||||
|     "v-tooltip": "^4.0.0-alpha.1", |     "v-tooltip": "^4.0.0-alpha.1", | ||||||
|     "vue": "^3.2.0-beta.5", |     "vue": "^3.2.0-beta.5", | ||||||
|     "vue-flatpickr-component": "^9.0.3", |     "vue-flatpickr-component": "^9.0.3", | ||||||
|  | |||||||
| @ -47,6 +47,8 @@ const ExpenseCategory = () => | |||||||
|   import('@/scripts/admin/views/settings/ExpenseCategorySetting.vue') |   import('@/scripts/admin/views/settings/ExpenseCategorySetting.vue') | ||||||
| const ExchangeRateSetting = () => | const ExchangeRateSetting = () => | ||||||
|   import('@/scripts/admin/views/settings/ExchangeRateProviderSetting.vue') |   import('@/scripts/admin/views/settings/ExchangeRateProviderSetting.vue') | ||||||
|  | const MailConfig = () => | ||||||
|  |   import('@/scripts/admin/views/settings/MailConfigSetting.vue') | ||||||
| const FileDisk = () => | const FileDisk = () => | ||||||
|   import('@/scripts/admin/views/settings/FileDiskSetting.vue') |   import('@/scripts/admin/views/settings/FileDiskSetting.vue') | ||||||
| const Backup = () => import('@/scripts/admin/views/settings/BackupSetting.vue') | const Backup = () => import('@/scripts/admin/views/settings/BackupSetting.vue') | ||||||
| @ -54,8 +56,6 @@ const UpdateApp = () => | |||||||
|   import('@/scripts/admin/views/settings/UpdateAppSetting.vue') |   import('@/scripts/admin/views/settings/UpdateAppSetting.vue') | ||||||
| const RolesSettings = () => | const RolesSettings = () => | ||||||
|   import('@/scripts/admin/views/settings/RolesSettings.vue') |   import('@/scripts/admin/views/settings/RolesSettings.vue') | ||||||
| const MailSender = () => |  | ||||||
|   import('@/scripts/admin/views/settings/mail-sender/Index.vue') |  | ||||||
|  |  | ||||||
| // Items | // Items | ||||||
| const ItemsIndex = () => import('@/scripts/admin/views/items/Index.vue') | const ItemsIndex = () => import('@/scripts/admin/views/items/Index.vue') | ||||||
| @ -302,6 +302,13 @@ export default [ | |||||||
|             meta: { ability: abilities.VIEW_EXPENSE }, |             meta: { ability: abilities.VIEW_EXPENSE }, | ||||||
|             component: ExpenseCategory, |             component: ExpenseCategory, | ||||||
|           }, |           }, | ||||||
|  |  | ||||||
|  |           { | ||||||
|  |             path: 'mail-configuration', | ||||||
|  |             name: 'mailconfig', | ||||||
|  |             meta: { isOwner: true }, | ||||||
|  |             component: MailConfig, | ||||||
|  |           }, | ||||||
|           { |           { | ||||||
|             path: 'file-disk', |             path: 'file-disk', | ||||||
|             name: 'file-disk', |             name: 'file-disk', | ||||||
| @ -320,13 +327,6 @@ export default [ | |||||||
|             meta: { isOwner: true }, |             meta: { isOwner: true }, | ||||||
|             component: UpdateApp, |             component: UpdateApp, | ||||||
|           }, |           }, | ||||||
|           { |  | ||||||
|             path: 'mail-sender', |  | ||||||
|             name: 'mailsender', |  | ||||||
|             meta: { ability: abilities.VIEW_MAIL_SENDER }, |  | ||||||
|             component: MailSender, |  | ||||||
|           }, |  | ||||||
|  |  | ||||||
|         ], |         ], | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ | |||||||
|       py-2 |       py-2 | ||||||
|       rounded-lg |       rounded-lg | ||||||
|       bg-opacity-40 bg-gray-300 |       bg-opacity-40 bg-gray-300 | ||||||
|  |       dark:bg-gray-700 dark:border-gray-600 | ||||||
|       whitespace-nowrap |       whitespace-nowrap | ||||||
|       flex-col |       flex-col | ||||||
|       mt-1 |       mt-1 | ||||||
| @ -19,6 +20,7 @@ | |||||||
|         text-sm |         text-sm | ||||||
|         font-medium |         font-medium | ||||||
|         text-black |         text-black | ||||||
|  |         dark:text-white | ||||||
|         truncate |         truncate | ||||||
|         select-all select-color |         select-all select-color | ||||||
|       " |       " | ||||||
|  | |||||||
| @ -1,123 +0,0 @@ | |||||||
| <template> |  | ||||||
|   <!-- warning alert --> |  | ||||||
|   <div |  | ||||||
|     v-if="type == 'warning'" |  | ||||||
|     class="rounded-md p-4 m-5" |  | ||||||
|     :class="{ |  | ||||||
|       'bg-yellow-50': type == 'warning', |  | ||||||
|       'bg-blue-50': type == 'info', |  | ||||||
|       'bg-red-50': type == 'error', |  | ||||||
|       'bg-green-50': type == 'success', |  | ||||||
|     }" |  | ||||||
|   > |  | ||||||
|     <div class="flex"> |  | ||||||
|       <div class="flex-shrink-0"> |  | ||||||
|         <!-- Heroicon name: solid/exclamation --> |  | ||||||
|         <svg |  | ||||||
|           v-if="type == 'warning'" |  | ||||||
|           class="h-5 w-5 text-yellow-400" |  | ||||||
|           xmlns="http://www.w3.org/2000/svg" |  | ||||||
|           viewBox="0 0 20 20" |  | ||||||
|           fill="currentColor" |  | ||||||
|           aria-hidden="true" |  | ||||||
|         > |  | ||||||
|           <path |  | ||||||
|             fill-rule="evenodd" |  | ||||||
|             d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" |  | ||||||
|             clip-rule="evenodd" |  | ||||||
|           /> |  | ||||||
|         </svg> |  | ||||||
|         <!-- Heroicon name: solid/information-circle --> |  | ||||||
|         <svg |  | ||||||
|           v-else-if="type == 'info'" |  | ||||||
|           class="h-5 w-5 text-blue-400" |  | ||||||
|           xmlns="http://www.w3.org/2000/svg" |  | ||||||
|           viewBox="0 0 20 20" |  | ||||||
|           fill="currentColor" |  | ||||||
|           aria-hidden="true" |  | ||||||
|         > |  | ||||||
|           <path |  | ||||||
|             fill-rule="evenodd" |  | ||||||
|             d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" |  | ||||||
|             clip-rule="evenodd" |  | ||||||
|           /> |  | ||||||
|         </svg> |  | ||||||
|         <!-- Heroicon name: solid/x-circle --> |  | ||||||
|         <svg |  | ||||||
|           v-else-if="type == 'error'" |  | ||||||
|           class="h-5 w-5 text-red-400" |  | ||||||
|           xmlns="http://www.w3.org/2000/svg" |  | ||||||
|           viewBox="0 0 20 20" |  | ||||||
|           fill="currentColor" |  | ||||||
|           aria-hidden="true" |  | ||||||
|         > |  | ||||||
|           <path |  | ||||||
|             fill-rule="evenodd" |  | ||||||
|             d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" |  | ||||||
|             clip-rule="evenodd" |  | ||||||
|           /> |  | ||||||
|         </svg> |  | ||||||
|         <!-- Heroicon name: solid/check-circle --> |  | ||||||
|         <svg |  | ||||||
|           v-else |  | ||||||
|           class="h-5 w-5 text-green-400" |  | ||||||
|           xmlns="http://www.w3.org/2000/svg" |  | ||||||
|           viewBox="0 0 20 20" |  | ||||||
|           fill="currentColor" |  | ||||||
|           aria-hidden="true" |  | ||||||
|         > |  | ||||||
|           <path |  | ||||||
|             fill-rule="evenodd" |  | ||||||
|             d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" |  | ||||||
|             clip-rule="evenodd" |  | ||||||
|           /> |  | ||||||
|         </svg> |  | ||||||
|       </div> |  | ||||||
|       <div class="ml-3"> |  | ||||||
|         <h3 |  | ||||||
|           class="text-sm font-medium" |  | ||||||
|           :class="{ |  | ||||||
|             'text-yellow-800': type == 'warning', |  | ||||||
|             'text-blue-800': type == 'info', |  | ||||||
|             'text-red-800': type == 'error', |  | ||||||
|             'text-green-800': type == 'success', |  | ||||||
|           }" |  | ||||||
|         > |  | ||||||
|           {{ title }} |  | ||||||
|         </h3> |  | ||||||
|         <div |  | ||||||
|           class="text-sm" |  | ||||||
|           :class="{ |  | ||||||
|             'text-yellow-700': type == 'warning', |  | ||||||
|             'text-blue-700': type == 'info', |  | ||||||
|             'text-red-700': type == 'error', |  | ||||||
|             'text-green-700': type == 'success', |  | ||||||
|           }" |  | ||||||
|         > |  | ||||||
|           <p>{{ description }}</p> |  | ||||||
|         </div> |  | ||||||
|         <slot name="action"></slot> |  | ||||||
|       </div> |  | ||||||
|     </div> |  | ||||||
|   </div> |  | ||||||
| </template> |  | ||||||
|  |  | ||||||
| <script setup> |  | ||||||
| const props = defineProps({ |  | ||||||
|   title: { |  | ||||||
|     type: String, |  | ||||||
|     default: null, |  | ||||||
|     required: false, |  | ||||||
|   }, |  | ||||||
|   description: { |  | ||||||
|     type: String, |  | ||||||
|     default: null, |  | ||||||
|     required: false, |  | ||||||
|   }, |  | ||||||
|   type: { |  | ||||||
|     type: String, |  | ||||||
|     default: 'success', |  | ||||||
|     required: true, |  | ||||||
|   }, |  | ||||||
| }) |  | ||||||
| </script> |  | ||||||
| @ -43,6 +43,12 @@ | |||||||
|             max-w-full |             max-w-full | ||||||
|             left-0 |             left-0 | ||||||
|             top-3 |             top-3 | ||||||
|  |             bg-white | ||||||
|  |             dark:border | ||||||
|  |             dark:border-white/10 | ||||||
|  |             dark:text-white | ||||||
|  |             dark:bg-gray-800 | ||||||
|  |             dark:shadow-glass | ||||||
|           " |           " | ||||||
|         > |         > | ||||||
|           <div |           <div | ||||||
| @ -53,7 +59,7 @@ | |||||||
|               ring-1 ring-black ring-opacity-5 |               ring-1 ring-black ring-opacity-5 | ||||||
|             " |             " | ||||||
|           > |           > | ||||||
|             <div class="relative grid bg-white"> |             <div class="relative grid bg-white dark:bg-gray-800"> | ||||||
|               <div class="relative p-4"> |               <div class="relative p-4"> | ||||||
|                 <BaseInput |                 <BaseInput | ||||||
|                   v-model="textSearch" |                   v-model="textSearch" | ||||||
| @ -66,7 +72,7 @@ | |||||||
|  |  | ||||||
|               <div |               <div | ||||||
|                 v-if="filteredNotes.length > 0" |                 v-if="filteredNotes.length > 0" | ||||||
|                 class="relative flex flex-col overflow-auto list max-h-36" |                 class="relative flex flex-col overflow-auto list max-h-36 dark:border-white/10" | ||||||
|               > |               > | ||||||
|                 <div |                 <div | ||||||
|                   v-for="(note, index) in filteredNotes" |                   v-for="(note, index) in filteredNotes" | ||||||
| @ -79,6 +85,8 @@ | |||||||
|                     cursor-pointer |                     cursor-pointer | ||||||
|                     hover:bg-gray-100 hover:cursor-pointer |                     hover:bg-gray-100 hover:cursor-pointer | ||||||
|                     last:border-b-0 |                     last:border-b-0 | ||||||
|  |                     dark:border-gray-600 | ||||||
|  |                     dark:border-white/10 dark:hover:bg-gray-700/30 | ||||||
|                   " |                   " | ||||||
|                   @click="selectNote(index, close)" |                   @click="selectNote(index, close)" | ||||||
|                 > |                 > | ||||||
| @ -91,6 +99,7 @@ | |||||||
|                         leading-tight |                         leading-tight | ||||||
|                         text-gray-700 |                         text-gray-700 | ||||||
|                         cursor-pointer |                         cursor-pointer | ||||||
|  |                         dark:text-gray-400 | ||||||
|                       " |                       " | ||||||
|                     > |                     > | ||||||
|                       {{ note.name }} |                       {{ note.name }} | ||||||
| @ -118,6 +127,10 @@ | |||||||
|                 bg-gray-200 |                 bg-gray-200 | ||||||
|                 border-none |                 border-none | ||||||
|                 outline-none |                 outline-none | ||||||
|  |                 dark:bg-gray-600/70 | ||||||
|  |                 dark:backdrop-blur-xl | ||||||
|  |                 dark:shadow-glass | ||||||
|  |                 dark:hover:bg-gray-600/80 | ||||||
|               " |               " | ||||||
|               @click="openNoteModal" |               @click="openNoteModal" | ||||||
|             > |             > | ||||||
|  | |||||||
| @ -6,8 +6,17 @@ | |||||||
|  |  | ||||||
| <script setup> | <script setup> | ||||||
| import Chart from 'chart.js' | import Chart from 'chart.js' | ||||||
| import { ref, reactive, computed, onMounted, watchEffect, inject } from 'vue' | import { | ||||||
|  |   ref, | ||||||
|  |   reactive, | ||||||
|  |   computed, | ||||||
|  |   onMounted, | ||||||
|  |   watchEffect, | ||||||
|  |   inject, | ||||||
|  |   watch, | ||||||
|  | } from 'vue' | ||||||
| import { useCompanyStore } from '@/scripts/admin/stores/company' | import { useCompanyStore } from '@/scripts/admin/stores/company' | ||||||
|  | import { useGlobalStore } from '@/scripts/admin/stores/global' | ||||||
|  |  | ||||||
| const utils = inject('utils') | const utils = inject('utils') | ||||||
|  |  | ||||||
| @ -44,9 +53,11 @@ const props = defineProps({ | |||||||
|   }, |   }, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | const isDarkModeOn = document.documentElement.classList.contains('dark') | ||||||
| let myLineChart = null | let myLineChart = null | ||||||
| const graph = ref(null) | const graph = ref(null) | ||||||
| const companyStore = useCompanyStore() | const companyStore = useCompanyStore() | ||||||
|  | const globalStore = useGlobalStore() | ||||||
| const defaultCurrency = computed(() => { | const defaultCurrency = computed(() => { | ||||||
|   return companyStore.selectedCompanyCurrency |   return companyStore.selectedCompanyCurrency | ||||||
| }) | }) | ||||||
| @ -60,6 +71,14 @@ watchEffect(() => { | |||||||
|   } |   } | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | watch( | ||||||
|  |   () => globalStore.isDarkModeOn, | ||||||
|  |   () => { | ||||||
|  |     myLineChart.reset() | ||||||
|  |     updateColors() | ||||||
|  |   } | ||||||
|  | ) | ||||||
|  |  | ||||||
| onMounted(() => { | onMounted(() => { | ||||||
|   let context = graph.value.getContext('2d') |   let context = graph.value.getContext('2d') | ||||||
|   let options = reactive({ |   let options = reactive({ | ||||||
| @ -81,6 +100,8 @@ onMounted(() => { | |||||||
|     }, |     }, | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
|  |   const salesColor = globalStore.isDarkModeOn ? '#ffffff' : '#040405' | ||||||
|  |  | ||||||
|   let data = reactive({ |   let data = reactive({ | ||||||
|     labels: props.labels, |     labels: props.labels, | ||||||
|     datasets: [ |     datasets: [ | ||||||
| @ -89,16 +110,16 @@ onMounted(() => { | |||||||
|         fill: false, |         fill: false, | ||||||
|         lineTension: 0.3, |         lineTension: 0.3, | ||||||
|         backgroundColor: 'rgba(230, 254, 249)', |         backgroundColor: 'rgba(230, 254, 249)', | ||||||
|         borderColor: '#040405', |         borderColor: salesColor, | ||||||
|         borderCapStyle: 'butt', |         borderCapStyle: 'butt', | ||||||
|         borderDash: [], |         borderDash: [], | ||||||
|         borderDashOffset: 0.0, |         borderDashOffset: 0.0, | ||||||
|         borderJoinStyle: 'miter', |         borderJoinStyle: 'miter', | ||||||
|         pointBorderColor: '#040405', |         pointBorderColor: salesColor, | ||||||
|         pointBackgroundColor: '#fff', |         pointBackgroundColor: '#fff', | ||||||
|         pointBorderWidth: 1, |         pointBorderWidth: 1, | ||||||
|         pointHoverRadius: 5, |         pointHoverRadius: 5, | ||||||
|         pointHoverBackgroundColor: '#040405', |         pointHoverBackgroundColor: salesColor, | ||||||
|         pointHoverBorderColor: 'rgba(220,220,220,1)', |         pointHoverBorderColor: 'rgba(220,220,220,1)', | ||||||
|         pointHoverBorderWidth: 2, |         pointHoverBorderWidth: 2, | ||||||
|         pointRadius: 4, |         pointRadius: 4, | ||||||
| @ -194,4 +215,12 @@ function update() { | |||||||
|     lazy: true, |     lazy: true, | ||||||
|   }) |   }) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function updateColors() { | ||||||
|  |   const newColor = globalStore.isDarkModeOn ? '#ffffff' : '#040405' | ||||||
|  |  | ||||||
|  |   myLineChart.data.datasets[0].borderColor = newColor | ||||||
|  |   myLineChart.data.datasets[0].pointBorderColor = newColor | ||||||
|  |   myLineChart.data.datasets[0].pointHoverBackgroundColor = newColor | ||||||
|  | } | ||||||
| </script> | </script> | ||||||
|  | |||||||
| @ -50,21 +50,11 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </template> |         </template> | ||||||
|       </ValidateEach> |       </ValidateEach> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         slot="footer" |  | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           mt-4 |  | ||||||
|           pt-4 |  | ||||||
|           border-t border-gray-200 border-solid border-modal-bg |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton :loading="isSaving" variant="primary" type="submit"> |         <BaseButton :loading="isSaving" variant="primary" type="submit"> | ||||||
|           {{ $t('general.save') }} |           {{ $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseCard> |   </BaseCard> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -64,7 +64,7 @@ function mergeExistingValues() { | |||||||
|   if (props.isEdit) { |   if (props.isEdit) { | ||||||
|     props.store[props.storeProp].fields.forEach((field) => { |     props.store[props.storeProp].fields.forEach((field) => { | ||||||
|       const existingIndex = props.store[props.storeProp].customFields.findIndex( |       const existingIndex = props.store[props.storeProp].customFields.findIndex( | ||||||
|         (f) => f.id === field.custom_field_id |         (f) => f.id == field.custom_field_id | ||||||
|       ) |       ) | ||||||
|  |  | ||||||
|       if (existingIndex > -1) { |       if (existingIndex > -1) { | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ import { computed } from 'vue' | |||||||
| const props = defineProps({ | const props = defineProps({ | ||||||
|   modelValue: { |   modelValue: { | ||||||
|     type: String, |     type: String, | ||||||
|     default: moment().format('YYYY-MM-DD hh:MM'), |     default: moment().format('YYYY-MM-DD HH:mm'), | ||||||
|   }, |   }, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | |||||||
| @ -7,11 +7,12 @@ | |||||||
|     <!-- edit customField  --> |     <!-- edit customField  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_CUSTOM_FIELDS)" |       v-if="userStore.hasAbilities(abilities.EDIT_CUSTOM_FIELDS)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="editCustomField(row.id)" |       @click="editCustomField(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PencilIcon" |         name="PencilIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.edit') }} |       {{ $t('general.edit') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -19,11 +20,12 @@ | |||||||
|     <!-- delete customField  --> |     <!-- delete customField  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_CUSTOM_FIELDS)" |       v-if="userStore.hasAbilities(abilities.DELETE_CUSTOM_FIELDS)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeCustomField(row.id)" |       @click="removeCustomField(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -12,10 +12,10 @@ | |||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_CUSTOMER)" |       v-if="userStore.hasAbilities(abilities.EDIT_CUSTOMER)" | ||||||
|       :to="`/admin/customers/${row.id}/edit`" |       :to="`/admin/customers/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -29,10 +29,10 @@ | |||||||
|       " |       " | ||||||
|       :to="`customers/${row.id}/view`" |       :to="`customers/${row.id}/view`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="EyeIcon" |           name="EyeIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.view') }} |         {{ $t('general.view') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -41,11 +41,12 @@ | |||||||
|     <!-- Delete Customer  --> |     <!-- Delete Customer  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_CUSTOMER)" |       v-if="userStore.hasAbilities(abilities.DELETE_CUSTOMER)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeCustomer(row.id)" |       @click="removeCustomer(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -10,11 +10,12 @@ | |||||||
|     <!-- Copy PDF url  --> |     <!-- Copy PDF url  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="route.name === 'estimates.view'" |       v-if="route.name === 'estimates.view'" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="copyPdfUrl" |       @click="copyPdfUrl" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="LinkIcon" |         name="LinkIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.copy_pdf_url') }} |       {{ $t('general.copy_pdf_url') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -24,10 +25,10 @@ | |||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_ESTIMATE)" |       v-if="userStore.hasAbilities(abilities.EDIT_ESTIMATE)" | ||||||
|       :to="`/admin/estimates/${row.id}/edit`" |       :to="`/admin/estimates/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -36,11 +37,12 @@ | |||||||
|     <!-- Delete Estimate  --> |     <!-- Delete Estimate  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_ESTIMATE)" |       v-if="userStore.hasAbilities(abilities.DELETE_ESTIMATE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeEstimate(row.id)" |       @click="removeEstimate(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -53,10 +55,10 @@ | |||||||
|       " |       " | ||||||
|       :to="`estimates/${row.id}/view`" |       :to="`estimates/${row.id}/view`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="EyeIcon" |           name="EyeIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.view') }} |         {{ $t('general.view') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -65,11 +67,12 @@ | |||||||
|     <!-- Convert into Invoice  --> |     <!-- Convert into Invoice  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.CREATE_INVOICE)" |       v-if="userStore.hasAbilities(abilities.CREATE_INVOICE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="convertInToinvoice(row.id)" |       @click="convertInToinvoice(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="DocumentTextIcon" |         name="DocumentTextIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('estimates.convert_to_invoice') }} |       {{ $t('estimates.convert_to_invoice') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -81,11 +84,12 @@ | |||||||
|         route.name !== 'estimates.view' && |         route.name !== 'estimates.view' && | ||||||
|         userStore.hasAbilities(abilities.SEND_ESTIMATE) |         userStore.hasAbilities(abilities.SEND_ESTIMATE) | ||||||
|       " |       " | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="onMarkAsSent(row.id)" |       @click="onMarkAsSent(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="CheckCircleIcon" |         name="CheckCircleIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('estimates.mark_as_sent') }} |       {{ $t('estimates.mark_as_sent') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -97,20 +101,21 @@ | |||||||
|         route.name !== 'estimates.view' && |         route.name !== 'estimates.view' && | ||||||
|         userStore.hasAbilities(abilities.SEND_ESTIMATE) |         userStore.hasAbilities(abilities.SEND_ESTIMATE) | ||||||
|       " |       " | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="sendEstimate(row)" |       @click="sendEstimate(row)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PaperAirplaneIcon" |         name="PaperAirplaneIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('estimates.send_estimate') }} |       {{ $t('estimates.send_estimate') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  |  | ||||||
|     <!-- Resend Estimate --> |     <!-- Resend Estimate --> | ||||||
|     <BaseDropdownItem v-if="canResendEstimate(row)" @click="sendEstimate(row)"> |     <BaseDropdownItem v-if="canResendEstimate(row)" v-slot="slotProps"  @click="sendEstimate(row)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PaperAirplaneIcon" |         name="PaperAirplaneIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('estimates.resend_estimate') }} |       {{ $t('estimates.resend_estimate') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -121,11 +126,12 @@ | |||||||
|         row.status !== 'ACCEPTED' && |         row.status !== 'ACCEPTED' && | ||||||
|         userStore.hasAbilities(abilities.EDIT_ESTIMATE) |         userStore.hasAbilities(abilities.EDIT_ESTIMATE) | ||||||
|       " |       " | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="onMarkAsAccepted(row.id)" |       @click="onMarkAsAccepted(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="CheckCircleIcon" |         name="CheckCircleIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('estimates.mark_as_accepted') }} |       {{ $t('estimates.mark_as_accepted') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -136,11 +142,12 @@ | |||||||
|         row.status !== 'REJECTED' && |         row.status !== 'REJECTED' && | ||||||
|         userStore.hasAbilities(abilities.EDIT_ESTIMATE) |         userStore.hasAbilities(abilities.EDIT_ESTIMATE) | ||||||
|       " |       " | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="onMarkAsRejected(row.id)" |       @click="onMarkAsRejected(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="XCircleIcon" |         name="XCircleIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('estimates.mark_as_rejected') }} |       {{ $t('estimates.mark_as_rejected') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -13,11 +13,12 @@ | |||||||
|     <!-- edit expenseCategory  --> |     <!-- edit expenseCategory  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_EXPENSE)" |       v-if="userStore.hasAbilities(abilities.EDIT_EXPENSE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="editExpenseCategory(row.id)" |       @click="editExpenseCategory(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PencilIcon" |         name="PencilIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.edit') }} |       {{ $t('general.edit') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -25,11 +26,12 @@ | |||||||
|     <!-- delete expenseCategory  --> |     <!-- delete expenseCategory  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_EXPENSE)" |       v-if="userStore.hasAbilities(abilities.DELETE_EXPENSE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeExpenseCategory(row.id)" |       @click="removeExpenseCategory(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -12,10 +12,10 @@ | |||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_EXPENSE)" |       v-if="userStore.hasAbilities(abilities.EDIT_EXPENSE)" | ||||||
|       :to="`/admin/expenses/${row.id}/edit`" |       :to="`/admin/expenses/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -24,11 +24,12 @@ | |||||||
|     <!-- delete expense  --> |     <!-- delete expense  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_EXPENSE)" |       v-if="userStore.hasAbilities(abilities.DELETE_EXPENSE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeExpense(row.id)" |       @click="removeExpense(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -12,20 +12,20 @@ | |||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_INVOICE)" |       v-if="userStore.hasAbilities(abilities.EDIT_INVOICE)" | ||||||
|       :to="`/admin/invoices/${row.id}/edit`" |       :to="`/admin/invoices/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem v-show="row.allow_edit"> |       <BaseDropdownItem v-show="row.allow_edit" v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
|     </router-link> |     </router-link> | ||||||
|  |  | ||||||
|     <!-- Copy PDF url  --> |     <!-- Copy PDF url  --> | ||||||
|     <BaseDropdownItem v-if="route.name === 'invoices.view'" @click="copyPdfUrl"> |     <BaseDropdownItem v-if="route.name === 'invoices.view'" v-slot="slotProps" @click="copyPdfUrl"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="LinkIcon" |         name="LinkIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.copy_pdf_url') }} |       {{ $t('general.copy_pdf_url') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -38,29 +38,29 @@ | |||||||
|       " |       " | ||||||
|       :to="`/admin/invoices/${row.id}/view`" |       :to="`/admin/invoices/${row.id}/view`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="EyeIcon" |           name="EyeIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.view') }} |         {{ $t('general.view') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
|     </router-link> |     </router-link> | ||||||
|  |  | ||||||
|     <!-- Send Invoice Mail  --> |     <!-- Send Invoice Mail  --> | ||||||
|     <BaseDropdownItem v-if="canSendInvoice(row)" @click="sendInvoice(row)"> |     <BaseDropdownItem v-if="canSendInvoice(row)" v-slot="slotProps" @click="sendInvoice(row)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PaperAirplaneIcon" |         name="PaperAirplaneIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('invoices.send_invoice') }} |       {{ $t('invoices.send_invoice') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  |  | ||||||
|     <!-- Resend Invoice --> |     <!-- Resend Invoice --> | ||||||
|     <BaseDropdownItem v-if="canReSendInvoice(row)" @click="sendInvoice(row)"> |     <BaseDropdownItem v-if="canReSendInvoice(row)" v-slot="slotProps" @click="sendInvoice(row)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PaperAirplaneIcon" |         name="PaperAirplaneIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('invoices.resend_invoice') }} |       {{ $t('invoices.resend_invoice') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -69,20 +69,21 @@ | |||||||
|     <router-link :to="`/admin/payments/${row.id}/create`"> |     <router-link :to="`/admin/payments/${row.id}/create`"> | ||||||
|       <BaseDropdownItem |       <BaseDropdownItem | ||||||
|         v-if="row.status == 'SENT' && route.name !== 'invoices.view'" |         v-if="row.status == 'SENT' && route.name !== 'invoices.view'" | ||||||
|  |         v-slot="slotProps" | ||||||
|       > |       > | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="CreditCardIcon" |           name="CreditCardIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('invoices.record_payment') }} |         {{ $t('invoices.record_payment') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
|     </router-link> |     </router-link> | ||||||
|  |  | ||||||
|     <!-- Mark as sent Invoice --> |     <!-- Mark as sent Invoice --> | ||||||
|     <BaseDropdownItem v-if="canSendInvoice(row)" @click="onMarkAsSent(row.id)"> |     <BaseDropdownItem v-if="canSendInvoice(row)" v-slot="slotProps" @click="onMarkAsSent(row.id)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="CheckCircleIcon" |         name="CheckCircleIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('invoices.mark_as_sent') }} |       {{ $t('invoices.mark_as_sent') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -90,11 +91,12 @@ | |||||||
|     <!-- Clone Invoice into new invoice  --> |     <!-- Clone Invoice into new invoice  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.CREATE_INVOICE)" |       v-if="userStore.hasAbilities(abilities.CREATE_INVOICE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="cloneInvoiceData(row)" |       @click="cloneInvoiceData(row)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="DocumentTextIcon" |         name="DocumentTextIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('invoices.clone_invoice') }} |       {{ $t('invoices.clone_invoice') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -102,11 +104,12 @@ | |||||||
|     <!--  Delete Invoice  --> |     <!--  Delete Invoice  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_INVOICE)" |       v-if="userStore.hasAbilities(abilities.DELETE_INVOICE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeInvoice(row.id)" |       @click="removeInvoice(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -12,11 +12,8 @@ | |||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_ITEM)" |       v-if="userStore.hasAbilities(abilities.EDIT_ITEM)" | ||||||
|       :to="`/admin/items/${row.id}/edit`" |       :to="`/admin/items/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon name="PencilIcon" :class="slotProps.class" /> | ||||||
|           name="PencilIcon" |  | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |  | ||||||
|         /> |  | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
|     </router-link> |     </router-link> | ||||||
| @ -24,12 +21,10 @@ | |||||||
|     <!-- delete item  --> |     <!-- delete item  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_ITEM)" |       v-if="userStore.hasAbilities(abilities.DELETE_ITEM)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeItem(row.id)" |       @click="removeItem(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon name="TrashIcon" :class="slotProps.class" /> | ||||||
|         name="TrashIcon" |  | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |  | ||||||
|       /> |  | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|   </BaseDropdown> |   </BaseDropdown> | ||||||
|  | |||||||
| @ -1,111 +0,0 @@ | |||||||
| <template> |  | ||||||
|   <BaseDropdown> |  | ||||||
|     <template #activator> |  | ||||||
|       <BaseButton v-if="route.name === 'mailsender.view'" variant="primary"> |  | ||||||
|         <BaseIcon name="DotsHorizontalIcon" class="h-5 text-white" /> |  | ||||||
|       </BaseButton> |  | ||||||
|       <BaseIcon v-else name="DotsHorizontalIcon" class="h-5 text-gray-500" /> |  | ||||||
|     </template> |  | ||||||
|  |  | ||||||
|     <!-- edit mail-sender  --> |  | ||||||
|     <BaseDropdownItem @click="editMailSender(row.id)"> |  | ||||||
|       <BaseIcon |  | ||||||
|         name="PencilIcon" |  | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |  | ||||||
|       /> |  | ||||||
|       {{ $t('general.edit') }} |  | ||||||
|     </BaseDropdownItem> |  | ||||||
|  |  | ||||||
|     <!-- send test mail-sender  --> |  | ||||||
|     <BaseDropdownItem @click="openMailSenderTestModal(row.id)"> |  | ||||||
|       <BaseIcon |  | ||||||
|         name="PaperAirplaneIcon" |  | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |  | ||||||
|       /> |  | ||||||
|       {{ $t('general.send_test_mail') }} |  | ||||||
|     </BaseDropdownItem> |  | ||||||
|  |  | ||||||
|     <!-- delete mail-sender  --> |  | ||||||
|     <BaseDropdownItem v-if="!row.is_default" @click="removeMailSender(row.id)"> |  | ||||||
|       <BaseIcon |  | ||||||
|         name="TrashIcon" |  | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |  | ||||||
|       /> |  | ||||||
|       {{ $t('general.delete') }} |  | ||||||
|     </BaseDropdownItem> |  | ||||||
|   </BaseDropdown> |  | ||||||
| </template> |  | ||||||
|  |  | ||||||
| <script setup> |  | ||||||
| import { useDialogStore } from '@/scripts/stores/dialog' |  | ||||||
| import { useI18n } from 'vue-i18n' |  | ||||||
| import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender' |  | ||||||
| import { useRoute, useRouter } from 'vue-router' |  | ||||||
| import { inject } from 'vue' |  | ||||||
| import { useModalStore } from '@/scripts/stores/modal' |  | ||||||
|  |  | ||||||
| const props = defineProps({ |  | ||||||
|   row: { |  | ||||||
|     type: Object, |  | ||||||
|     default: null, |  | ||||||
|   }, |  | ||||||
|   table: { |  | ||||||
|     type: Object, |  | ||||||
|     default: null, |  | ||||||
|   }, |  | ||||||
|   loadData: { |  | ||||||
|     type: Function, |  | ||||||
|     default: null, |  | ||||||
|   }, |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| const pre_t = 'settings.mail_sender' |  | ||||||
| const dialogStore = useDialogStore() |  | ||||||
| const { t } = useI18n() |  | ||||||
| const mailSenderStore = useMailSenderStore() |  | ||||||
| const route = useRoute() |  | ||||||
| const modalStore = useModalStore() |  | ||||||
|  |  | ||||||
| async function editMailSender(id) { |  | ||||||
|   await mailSenderStore.fetchMailSender(id) |  | ||||||
|   modalStore.openModal({ |  | ||||||
|     title: t(`${pre_t}.edit_mail_sender`), |  | ||||||
|     componentName: 'MailSenderModal', |  | ||||||
|     size: 'md', |  | ||||||
|     refreshData: props.loadData && props.loadData, |  | ||||||
|   }) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function removeMailSender(id) { |  | ||||||
|   dialogStore |  | ||||||
|     .openDialog({ |  | ||||||
|       title: t('general.are_you_sure'), |  | ||||||
|       message: t(`${pre_t}.confirm_delete`), |  | ||||||
|       yesLabel: t('general.ok'), |  | ||||||
|       noLabel: t('general.cancel'), |  | ||||||
|       variant: 'danger', |  | ||||||
|       hideNoButton: false, |  | ||||||
|       size: 'lg', |  | ||||||
|     }) |  | ||||||
|     .then(async (res) => { |  | ||||||
|       if (res) { |  | ||||||
|         let response = await mailSenderStore.deleteMailSender(id) |  | ||||||
|         if (response.data.success) { |  | ||||||
|           props.loadData && props.loadData() |  | ||||||
|           return true |  | ||||||
|         } |  | ||||||
|         props.loadData && props.loadData() |  | ||||||
|       } |  | ||||||
|     }) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| async function openMailSenderTestModal(id) { |  | ||||||
|   modalStore.openModal({ |  | ||||||
|     title: t(`general.send_test_mail`), |  | ||||||
|     componentName: 'MailSenderTestModal', |  | ||||||
|     size: 'md', |  | ||||||
|     id: id, |  | ||||||
|     refreshData: props.loadData && props.loadData, |  | ||||||
|   }) |  | ||||||
| } |  | ||||||
| </script> |  | ||||||
| @ -10,11 +10,12 @@ | |||||||
|     <!-- edit note  --> |     <!-- edit note  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.MANAGE_NOTE)" |       v-if="userStore.hasAbilities(abilities.MANAGE_NOTE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="editNote(row.id)" |       @click="editNote(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PencilIcon" |         name="PencilIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.edit') }} |       {{ $t('general.edit') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -22,11 +23,12 @@ | |||||||
|     <!-- delete note  --> |     <!-- delete note  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.MANAGE_NOTE)" |       v-if="userStore.hasAbilities(abilities.MANAGE_NOTE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeNote(row.id)" |       @click="removeNote(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -8,30 +8,31 @@ | |||||||
|     </template> |     </template> | ||||||
|  |  | ||||||
|     <!-- Copy pdf url  --> |     <!-- Copy pdf url  --> | ||||||
|     <BaseDropdown-item |     <BaseDropdownItem | ||||||
|       v-if=" |       v-if=" | ||||||
|         route.name === 'payments.view' && |         route.name === 'payments.view' && | ||||||
|         userStore.hasAbilities(abilities.VIEW_PAYMENT) |         userStore.hasAbilities(abilities.VIEW_PAYMENT) | ||||||
|       " |       " | ||||||
|  |       v-slot="slotProps" | ||||||
|       class="rounded-md" |       class="rounded-md" | ||||||
|       @click="copyPdfUrl" |       @click="copyPdfUrl" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="LinkIcon" |         name="LinkIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.copy_pdf_url') }} |       {{ $t('general.copy_pdf_url') }} | ||||||
|     </BaseDropdown-item> |     </BaseDropdownItem> | ||||||
|  |  | ||||||
|     <!-- edit payment  --> |     <!-- edit payment  --> | ||||||
|     <router-link |     <router-link | ||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_PAYMENT)" |       v-if="userStore.hasAbilities(abilities.EDIT_PAYMENT)" | ||||||
|       :to="`/admin/payments/${row.id}/edit`" |       :to="`/admin/payments/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -45,10 +46,10 @@ | |||||||
|       " |       " | ||||||
|       :to="`/admin/payments/${row.id}/view`" |       :to="`/admin/payments/${row.id}/view`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="EyeIcon" |           name="EyeIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.view') }} |         {{ $t('general.view') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -61,11 +62,12 @@ | |||||||
|         route.name !== 'payments.view' && |         route.name !== 'payments.view' && | ||||||
|         userStore.hasAbilities(abilities.SEND_PAYMENT) |         userStore.hasAbilities(abilities.SEND_PAYMENT) | ||||||
|       " |       " | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="sendPayment(row)" |       @click="sendPayment(row)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PaperAirplaneIcon" |         name="PaperAirplaneIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('payments.send_payment') }} |       {{ $t('payments.send_payment') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -73,11 +75,12 @@ | |||||||
|     <!-- delete payment  --> |     <!-- delete payment  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_PAYMENT)" |       v-if="userStore.hasAbilities(abilities.DELETE_PAYMENT)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removePayment(row.id)" |       @click="removePayment(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -8,19 +8,19 @@ | |||||||
|     </template> |     </template> | ||||||
|  |  | ||||||
|     <!-- edit paymentMode  --> |     <!-- edit paymentMode  --> | ||||||
|     <BaseDropdownItem @click="editPaymentMode(row.id)"> |     <BaseDropdownItem v-slot="slotProps"  @click="editPaymentMode(row.id)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PencilIcon" |         name="PencilIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.edit') }} |       {{ $t('general.edit') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  |  | ||||||
|     <!-- delete paymentMode  --> |     <!-- delete paymentMode  --> | ||||||
|     <BaseDropdownItem @click="removePaymentMode(row.id)"> |     <BaseDropdownItem v-slot="slotProps"  @click="removePaymentMode(row.id)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -15,10 +15,10 @@ | |||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_RECURRING_INVOICE)" |       v-if="userStore.hasAbilities(abilities.EDIT_RECURRING_INVOICE)" | ||||||
|       :to="`/admin/recurring-invoices/${row.id}/edit`" |       :to="`/admin/recurring-invoices/${row.id}/edit`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -32,10 +32,10 @@ | |||||||
|       " |       " | ||||||
|       :to="`recurring-invoices/${row.id}/view`" |       :to="`recurring-invoices/${row.id}/view`" | ||||||
|     > |     > | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="EyeIcon" |           name="EyeIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.view') }} |         {{ $t('general.view') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
| @ -44,11 +44,12 @@ | |||||||
|     <!-- Delete Recurring Invoice  --> |     <!-- Delete Recurring Invoice  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_RECURRING_INVOICE)" |       v-if="userStore.hasAbilities(abilities.DELETE_RECURRING_INVOICE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeMultipleRecurringInvoices(row.id)" |       @click="removeMultipleRecurringInvoices(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -10,11 +10,12 @@ | |||||||
|     <!-- edit role  --> |     <!-- edit role  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.currentUser.is_owner" |       v-if="userStore.currentUser.is_owner" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="editRole(row.id)" |       @click="editRole(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PencilIcon" |         name="PencilIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.edit') }} |       {{ $t('general.edit') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -22,11 +23,12 @@ | |||||||
|     <!-- delete role  --> |     <!-- delete role  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.currentUser.is_owner" |       v-if="userStore.currentUser.is_owner" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeRole(row.id)" |       @click="removeRole(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -10,11 +10,12 @@ | |||||||
|     <!-- edit tax-type  --> |     <!-- edit tax-type  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.EDIT_TAX_TYPE)" |       v-if="userStore.hasAbilities(abilities.EDIT_TAX_TYPE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="editTaxType(row.id)" |       @click="editTaxType(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="PencilIcon" |         name="PencilIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.edit') }} |       {{ $t('general.edit') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
| @ -22,11 +23,12 @@ | |||||||
|     <!-- delete tax-type  --> |     <!-- delete tax-type  --> | ||||||
|     <BaseDropdownItem |     <BaseDropdownItem | ||||||
|       v-if="userStore.hasAbilities(abilities.DELETE_TAX_TYPE)" |       v-if="userStore.hasAbilities(abilities.DELETE_TAX_TYPE)" | ||||||
|  |       v-slot="slotProps" | ||||||
|       @click="removeTaxType(row.id)" |       @click="removeTaxType(row.id)" | ||||||
|     > |     > | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -9,20 +9,20 @@ | |||||||
|  |  | ||||||
|     <!-- edit user  --> |     <!-- edit user  --> | ||||||
|     <router-link :to="`/admin/users/${row.id}/edit`"> |     <router-link :to="`/admin/users/${row.id}/edit`"> | ||||||
|       <BaseDropdownItem> |       <BaseDropdownItem v-slot="slotProps"> | ||||||
|         <BaseIcon |         <BaseIcon | ||||||
|           name="PencilIcon" |           name="PencilIcon" | ||||||
|           class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |           :class="slotProps.class" | ||||||
|         /> |         /> | ||||||
|         {{ $t('general.edit') }} |         {{ $t('general.edit') }} | ||||||
|       </BaseDropdownItem> |       </BaseDropdownItem> | ||||||
|     </router-link> |     </router-link> | ||||||
|  |  | ||||||
|     <!-- delete user  --> |     <!-- delete user  --> | ||||||
|     <BaseDropdownItem @click="removeUser(row.id)"> |     <BaseDropdownItem v-slot="slotProps" @click="removeUser(row.id)"> | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="w-5 h-5 mr-3 text-gray-400 group-hover:text-gray-500" |         :class="slotProps.class" | ||||||
|       /> |       /> | ||||||
|       {{ $t('general.delete') }} |       {{ $t('general.delete') }} | ||||||
|     </BaseDropdownItem> |     </BaseDropdownItem> | ||||||
|  | |||||||
| @ -1,5 +1,13 @@ | |||||||
| <template> | <template> | ||||||
|   <tr class="box-border bg-white border border-gray-200 border-solid rounded-b"> |   <tr | ||||||
|  |     class=" | ||||||
|  |       box-border | ||||||
|  |       bg-white | ||||||
|  |       border border-gray-200 border-solid | ||||||
|  |       rounded-b | ||||||
|  |       dark:shadow-glass dark:border dark:border-white/10 dark:bg-gray-800/70 | ||||||
|  |       " | ||||||
|  |     > | ||||||
|     <td colspan="5" class="p-0 text-left align-top"> |     <td colspan="5" class="p-0 text-left align-top"> | ||||||
|       <table class="w-full"> |       <table class="w-full"> | ||||||
|         <colgroup> |         <colgroup> | ||||||
| @ -130,7 +138,7 @@ | |||||||
|                 <div class="flex items-center justify-center w-6 h-10 mx-2"> |                 <div class="flex items-center justify-center w-6 h-10 mx-2"> | ||||||
|                   <BaseIcon |                   <BaseIcon | ||||||
|                     v-if="showRemoveButton" |                     v-if="showRemoveButton" | ||||||
|                     class="h-5 text-gray-700 cursor-pointer" |                     class="h-5 dark:text-red-400 cursor-pointer" | ||||||
|                     name="TrashIcon" |                     name="TrashIcon" | ||||||
|                     @click="store.removeItem(index)" |                     @click="store.removeItem(index)" | ||||||
|                   /> |                   /> | ||||||
|  | |||||||
| @ -30,7 +30,22 @@ | |||||||
|         <template v-if="userStore.hasAbilities(ability)" #action> |         <template v-if="userStore.hasAbilities(ability)" #action> | ||||||
|           <button |           <button | ||||||
|             type="button" |             type="button" | ||||||
|             class="flex items-center justify-center w-full px-2 py-2 bg-gray-200 border-none outline-none cursor-pointer " |             class=" | ||||||
|  |               flex | ||||||
|  |               items-center | ||||||
|  |               justify-center | ||||||
|  |               w-full | ||||||
|  |               px-2 | ||||||
|  |               py-2 | ||||||
|  |               bg-gray-200 | ||||||
|  |               border-none | ||||||
|  |               outline-none | ||||||
|  |               cursor-pointer | ||||||
|  |               dark:bg-gray-600/70 | ||||||
|  |               dark:backdrop-blur-xl | ||||||
|  |               dark:shadow-glass | ||||||
|  |               dark:hover:bg-gray-600/80 | ||||||
|  |             " | ||||||
|             @click="openTaxModal" |             @click="openTaxModal" | ||||||
|           > |           > | ||||||
|             <BaseIcon name="CheckCircleIcon" class="h-5 text-primary-400" /> |             <BaseIcon name="CheckCircleIcon" class="h-5 text-primary-400" /> | ||||||
| @ -53,7 +68,7 @@ | |||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         v-if="taxes.length && index !== taxes.length - 1" |         v-if="taxes.length && index !== taxes.length - 1" | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="h-5 text-gray-700 cursor-pointer" |         class="h-5 text-gray-700 dark:text-red-400 cursor-pointer" | ||||||
|         @click="removeTax(index)" |         @click="removeTax(index)" | ||||||
|       /> |       /> | ||||||
|     </div> |     </div> | ||||||
|  | |||||||
| @ -1,155 +1,172 @@ | |||||||
| <template> | <template> | ||||||
|   <table class="text-center item-table min-w-full"> |   <div class="relative" > | ||||||
|     <colgroup> |     <BaseDarkHighlight class="z-[-1]" /> | ||||||
|       <col style="width: 40%; min-width: 280px" /> |     <table class="text-center item-table min-w-full"> | ||||||
|       <col style="width: 10%; min-width: 120px" /> |       <colgroup> | ||||||
|       <col style="width: 15%; min-width: 120px" /> |         <col style="width: 40%; min-width: 280px" /> | ||||||
|       <col |         <col style="width: 10%; min-width: 120px" /> | ||||||
|         v-if="store[storeProp].discount_per_item === 'YES'" |         <col style="width: 15%; min-width: 120px" /> | ||||||
|         style="width: 15%; min-width: 160px" |         <col | ||||||
|       /> |  | ||||||
|       <col style="width: 15%; min-width: 120px" /> |  | ||||||
|     </colgroup> |  | ||||||
|     <thead class="bg-white border border-gray-200 border-solid"> |  | ||||||
|       <tr> |  | ||||||
|         <th |  | ||||||
|           class=" |  | ||||||
|             px-5 |  | ||||||
|             py-3 |  | ||||||
|             text-sm |  | ||||||
|             not-italic |  | ||||||
|             font-medium |  | ||||||
|             leading-5 |  | ||||||
|             text-left text-gray-700 |  | ||||||
|             border-t border-b border-gray-200 border-solid |  | ||||||
|           " |  | ||||||
|         > |  | ||||||
|           <BaseContentPlaceholders v-if="isLoading"> |  | ||||||
|             <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> |  | ||||||
|           </BaseContentPlaceholders> |  | ||||||
|           <span v-else class="pl-7"> |  | ||||||
|             {{ $tc('items.item', 2) }} |  | ||||||
|           </span> |  | ||||||
|         </th> |  | ||||||
|         <th |  | ||||||
|           class=" |  | ||||||
|             px-5 |  | ||||||
|             py-3 |  | ||||||
|             text-sm |  | ||||||
|             not-italic |  | ||||||
|             font-medium |  | ||||||
|             leading-5 |  | ||||||
|             text-right text-gray-700 |  | ||||||
|             border-t border-b border-gray-200 border-solid |  | ||||||
|           " |  | ||||||
|         > |  | ||||||
|           <BaseContentPlaceholders v-if="isLoading"> |  | ||||||
|             <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> |  | ||||||
|           </BaseContentPlaceholders> |  | ||||||
|           <span v-else> |  | ||||||
|             {{ $t('invoices.item.quantity') }} |  | ||||||
|           </span> |  | ||||||
|         </th> |  | ||||||
|         <th |  | ||||||
|           class=" |  | ||||||
|             px-5 |  | ||||||
|             py-3 |  | ||||||
|             text-sm |  | ||||||
|             not-italic |  | ||||||
|             font-medium |  | ||||||
|             leading-5 |  | ||||||
|             text-left text-gray-700 |  | ||||||
|             border-t border-b border-gray-200 border-solid |  | ||||||
|           " |  | ||||||
|         > |  | ||||||
|           <BaseContentPlaceholders v-if="isLoading"> |  | ||||||
|             <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> |  | ||||||
|           </BaseContentPlaceholders> |  | ||||||
|           <span v-else> |  | ||||||
|             {{ $t('invoices.item.price') }} |  | ||||||
|           </span> |  | ||||||
|         </th> |  | ||||||
|         <th |  | ||||||
|           v-if="store[storeProp].discount_per_item === 'YES'" |           v-if="store[storeProp].discount_per_item === 'YES'" | ||||||
|           class=" |           style="width: 15%; min-width: 160px" | ||||||
|             px-5 |  | ||||||
|             py-3 |  | ||||||
|             text-sm |  | ||||||
|             not-italic |  | ||||||
|             font-medium |  | ||||||
|             leading-5 |  | ||||||
|             text-left text-gray-700 |  | ||||||
|             border-t border-b border-gray-200 border-solid |  | ||||||
|           " |  | ||||||
|         > |  | ||||||
|           <BaseContentPlaceholders v-if="isLoading"> |  | ||||||
|             <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> |  | ||||||
|           </BaseContentPlaceholders> |  | ||||||
|           <span v-else> |  | ||||||
|             {{ $t('invoices.item.discount') }} |  | ||||||
|           </span> |  | ||||||
|         </th> |  | ||||||
|         <th |  | ||||||
|           class=" |  | ||||||
|             px-5 |  | ||||||
|             py-3 |  | ||||||
|             text-sm |  | ||||||
|             not-italic |  | ||||||
|             font-medium |  | ||||||
|             leading-5 |  | ||||||
|             text-right text-gray-700 |  | ||||||
|             border-t border-b border-gray-200 border-solid |  | ||||||
|           " |  | ||||||
|         > |  | ||||||
|           <BaseContentPlaceholders v-if="isLoading"> |  | ||||||
|             <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> |  | ||||||
|           </BaseContentPlaceholders> |  | ||||||
|           <span v-else class="pr-10 column-heading"> |  | ||||||
|             {{ $t('invoices.item.amount') }} |  | ||||||
|           </span> |  | ||||||
|         </th> |  | ||||||
|       </tr> |  | ||||||
|     </thead> |  | ||||||
|     <draggable |  | ||||||
|       v-model="store[storeProp].items" |  | ||||||
|       item-key="id" |  | ||||||
|       tag="tbody" |  | ||||||
|       handle=".handle" |  | ||||||
|     > |  | ||||||
|       <template #item="{ element, index }"> |  | ||||||
|         <Item |  | ||||||
|           :key="element.id" |  | ||||||
|           :index="index" |  | ||||||
|           :item-data="element" |  | ||||||
|           :loading="isLoading" |  | ||||||
|           :currency="defaultCurrency" |  | ||||||
|           :item-validation-scope="itemValidationScope" |  | ||||||
|           :invoice-items="store[storeProp].items" |  | ||||||
|           :store="store" |  | ||||||
|           :store-prop="storeProp" |  | ||||||
|         /> |         /> | ||||||
|       </template> |         <col style="width: 15%; min-width: 120px" /> | ||||||
|     </draggable> |       </colgroup> | ||||||
|   </table> |       <thead | ||||||
|  |         class=" | ||||||
|  |           bg-white | ||||||
|  |           border | ||||||
|  |           border-gray-200 | ||||||
|  |           border-solid | ||||||
|  |           dark:shadow-glass dark:border dark:border-white/10 dark:bg-gray-800/70 | ||||||
|  |         " | ||||||
|  |       > | ||||||
|  |         <tr> | ||||||
|  |           <th | ||||||
|  |             class=" | ||||||
|  |               px-5 | ||||||
|  |               py-3 | ||||||
|  |               text-sm | ||||||
|  |               not-italic | ||||||
|  |               font-medium | ||||||
|  |               leading-5 | ||||||
|  |               text-left text-gray-700 | ||||||
|  |               border-t border-b border-gray-200 border-solid | ||||||
|  |               dark:text-white dark:border-white/10 | ||||||
|  |             " | ||||||
|  |           > | ||||||
|  |             <BaseContentPlaceholders v-if="isLoading"> | ||||||
|  |               <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> | ||||||
|  |             </BaseContentPlaceholders> | ||||||
|  |             <span v-else class="pl-7"> | ||||||
|  |               {{ $tc('items.item', 2) }} | ||||||
|  |             </span> | ||||||
|  |           </th> | ||||||
|  |           <th | ||||||
|  |             class=" | ||||||
|  |               px-5 | ||||||
|  |               py-3 | ||||||
|  |               text-sm | ||||||
|  |               not-italic | ||||||
|  |               font-medium | ||||||
|  |               leading-5 | ||||||
|  |               text-right text-gray-700 | ||||||
|  |               border-t border-b border-gray-200 border-solid | ||||||
|  |               dark:text-white dark:border-white/10 | ||||||
|  |             " | ||||||
|  |           > | ||||||
|  |             <BaseContentPlaceholders v-if="isLoading"> | ||||||
|  |               <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> | ||||||
|  |             </BaseContentPlaceholders> | ||||||
|  |             <span v-else> | ||||||
|  |               {{ $t('invoices.item.quantity') }} | ||||||
|  |             </span> | ||||||
|  |           </th> | ||||||
|  |           <th | ||||||
|  |             class=" | ||||||
|  |               px-5 | ||||||
|  |               py-3 | ||||||
|  |               text-sm | ||||||
|  |               not-italic | ||||||
|  |               font-medium | ||||||
|  |               leading-5 | ||||||
|  |               text-left text-gray-700 | ||||||
|  |               border-t border-b border-gray-200 border-solid | ||||||
|  |               dark:text-white dark:border-white/10 | ||||||
|  |             " | ||||||
|  |           > | ||||||
|  |             <BaseContentPlaceholders v-if="isLoading"> | ||||||
|  |               <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> | ||||||
|  |             </BaseContentPlaceholders> | ||||||
|  |             <span v-else> | ||||||
|  |               {{ $t('invoices.item.price') }} | ||||||
|  |             </span> | ||||||
|  |           </th> | ||||||
|  |           <th | ||||||
|  |             v-if="store[storeProp].discount_per_item === 'YES'" | ||||||
|  |             class=" | ||||||
|  |               px-5 | ||||||
|  |               py-3 | ||||||
|  |               text-sm | ||||||
|  |               not-italic | ||||||
|  |               font-medium | ||||||
|  |               leading-5 | ||||||
|  |               text-left text-gray-700 | ||||||
|  |               border-t border-b border-gray-200 border-solid | ||||||
|  |               dark:text-white dark:border-white/10 | ||||||
|  |             " | ||||||
|  |           > | ||||||
|  |             <BaseContentPlaceholders v-if="isLoading"> | ||||||
|  |               <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> | ||||||
|  |             </BaseContentPlaceholders> | ||||||
|  |             <span v-else> | ||||||
|  |               {{ $t('invoices.item.discount') }} | ||||||
|  |             </span> | ||||||
|  |           </th> | ||||||
|  |           <th | ||||||
|  |             class=" | ||||||
|  |               px-5 | ||||||
|  |               py-3 | ||||||
|  |               text-sm | ||||||
|  |               not-italic | ||||||
|  |               font-medium | ||||||
|  |               leading-5 | ||||||
|  |               text-right text-gray-700 | ||||||
|  |               border-t border-b border-gray-200 border-solid | ||||||
|  |               dark:text-white dark:border-white/10 | ||||||
|  |             " | ||||||
|  |           > | ||||||
|  |             <BaseContentPlaceholders v-if="isLoading"> | ||||||
|  |               <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> | ||||||
|  |             </BaseContentPlaceholders> | ||||||
|  |             <span v-else class="pr-10 column-heading"> | ||||||
|  |               {{ $t('invoices.item.amount') }} | ||||||
|  |             </span> | ||||||
|  |           </th> | ||||||
|  |         </tr> | ||||||
|  |       </thead> | ||||||
|  |       <draggable | ||||||
|  |         v-model="store[storeProp].items" | ||||||
|  |         item-key="id" | ||||||
|  |         tag="tbody" | ||||||
|  |         handle=".handle" | ||||||
|  |       > | ||||||
|  |         <template #item="{ element, index }"> | ||||||
|  |           <Item | ||||||
|  |             :key="element.id" | ||||||
|  |             :index="index" | ||||||
|  |             :item-data="element" | ||||||
|  |             :loading="isLoading" | ||||||
|  |             :currency="defaultCurrency" | ||||||
|  |             :item-validation-scope="itemValidationScope" | ||||||
|  |             :invoice-items="store[storeProp].items" | ||||||
|  |             :store="store" | ||||||
|  |             :store-prop="storeProp" | ||||||
|  |           /> | ||||||
|  |         </template> | ||||||
|  |       </draggable> | ||||||
|  |     </table> | ||||||
|  |  | ||||||
|   <div |     <div | ||||||
|     class=" |       class=" | ||||||
|       flex |         flex | ||||||
|       items-center |         items-center | ||||||
|       justify-center |         justify-center | ||||||
|       w-full |         w-full | ||||||
|       px-6 |         px-6 | ||||||
|       py-3 |         py-3 | ||||||
|       text-base |         text-base | ||||||
|       border border-t-0 border-gray-200 border-solid |         border border-t-0 border-gray-200 border-solid | ||||||
|       cursor-pointer |         cursor-pointer | ||||||
|       text-primary-400 |         text-primary-400 | ||||||
|       hover:bg-primary-100 |         hover:bg-primary-100 | ||||||
|     " |         dark:bg-gray-900/50 dark:border-white/10 dark:hover:bg-gray-900/80 | ||||||
|     @click="store.addItem" |       " | ||||||
|   > |       @click="store.addItem" | ||||||
|     <BaseIcon name="PlusCircleIcon" class="mr-2" /> |     > | ||||||
|     {{ $t('general.add_new_item') }} |       <BaseIcon name="PlusCircleIcon" class="mr-2" /> | ||||||
|  |       {{ $t('general.add_new_item') }} | ||||||
|  |     </div> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ | |||||||
|     > |     > | ||||||
|       <SelectNotePopup :type="type" @select="onSelectNote" /> |       <SelectNotePopup :type="type" @select="onSelectNote" /> | ||||||
|     </div> |     </div> | ||||||
|     <label class="text-gray-800 font-medium mb-4 text-sm"> |     <label class="text-gray-800 font-medium mb-4 text-sm dark:text-gray-300"> | ||||||
|       {{ $t('invoices.notes') }} |       {{ $t('invoices.notes') }} | ||||||
|     </label> |     </label> | ||||||
|     <BaseCustomInput |     <BaseCustomInput | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ | |||||||
|       mt-6 |       mt-6 | ||||||
|       bg-white |       bg-white | ||||||
|       border border-gray-200 border-solid |       border border-gray-200 border-solid | ||||||
|  |       dark:bg-gray-800/50 dark:border-white/10 | ||||||
|       rounded |       rounded | ||||||
|       md:min-w-[390px] |       md:min-w-[390px] | ||||||
|       min-w-[300px] |       min-w-[300px] | ||||||
| @ -29,7 +30,16 @@ | |||||||
|  |  | ||||||
|       <label |       <label | ||||||
|         v-else |         v-else | ||||||
|         class="flex items-center justify-center m-0 text-lg text-black uppercase " |         class=" | ||||||
|  |           flex | ||||||
|  |           items-center | ||||||
|  |           justify-center | ||||||
|  |           m-0 | ||||||
|  |           text-lg | ||||||
|  |           text-black | ||||||
|  |           dark:text-white | ||||||
|  |           uppercase | ||||||
|  |         " | ||||||
|       > |       > | ||||||
|         <BaseFormatMoney |         <BaseFormatMoney | ||||||
|           :amount="store.getSubTotal" |           :amount="store.getSubTotal" | ||||||
| @ -59,7 +69,16 @@ | |||||||
|  |  | ||||||
|       <label |       <label | ||||||
|         v-else-if="store[storeProp].tax_per_item === 'YES'" |         v-else-if="store[storeProp].tax_per_item === 'YES'" | ||||||
|         class="flex items-center justify-center m-0 text-lg text-black uppercase " |         class=" | ||||||
|  |           flex | ||||||
|  |           items-center | ||||||
|  |           justify-center | ||||||
|  |           m-0 | ||||||
|  |           text-lg | ||||||
|  |           text-black | ||||||
|  |           dark:text-white | ||||||
|  |           uppercase | ||||||
|  |         " | ||||||
|       > |       > | ||||||
|         <BaseFormatMoney :amount="tax.amount" :currency="defaultCurrency" /> |         <BaseFormatMoney :amount="tax.amount" :currency="defaultCurrency" /> | ||||||
|       </label> |       </label> | ||||||
| @ -166,14 +185,23 @@ | |||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <div |     <div | ||||||
|       class="flex items-center justify-between w-full pt-2 mt-5 border-t border-gray-200 border-solid " |       class=" | ||||||
|  |         flex | ||||||
|  |         items-center | ||||||
|  |         justify-between | ||||||
|  |         w-full | ||||||
|  |         pt-2 | ||||||
|  |         mt-5 | ||||||
|  |         border-t border-gray-200 border-solid | ||||||
|  |         dark:border-gray-600 | ||||||
|  |       " | ||||||
|     > |     > | ||||||
|       <BaseContentPlaceholders v-if="isLoading"> |       <BaseContentPlaceholders v-if="isLoading"> | ||||||
|         <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> |         <BaseContentPlaceholdersText :lines="1" class="w-16 h-5" /> | ||||||
|       </BaseContentPlaceholders> |       </BaseContentPlaceholders> | ||||||
|       <label |       <label | ||||||
|         v-else |         v-else | ||||||
|         class="m-0 text-sm font-semibold leading-5 text-gray-400 uppercase" |         class="m-0 text-sm font-semibold leading-5 text-gray-400 uppercase dark:text-gray-400" | ||||||
|         >{{ $t('estimates.total') }} {{ $t('estimates.amount') }}:</label |         >{{ $t('estimates.total') }} {{ $t('estimates.amount') }}:</label | ||||||
|       > |       > | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,14 +1,23 @@ | |||||||
| <template> | <template> | ||||||
|   <div class="flex items-center justify-between w-full mt-2 text-sm"> |   <div class="flex items-center justify-between w-full mt-2 text-sm"> | ||||||
|     <label class="font-semibold leading-5 text-gray-500 uppercase"> |     <label class="font-semibold leading-5 text-gray-500 uppercase dark:text-gray-300"> | ||||||
|       {{ tax.name }} ({{ tax.percent }} %) |       {{ tax.name }} ({{ tax.percent }} %) | ||||||
|     </label> |     </label> | ||||||
|     <label class="flex items-center justify-center text-lg text-black"> |     <label | ||||||
|  |       class=" | ||||||
|  |         flex | ||||||
|  |         items-center | ||||||
|  |         justify-center | ||||||
|  |         text-lg | ||||||
|  |         text-black | ||||||
|  |         dark:text-white | ||||||
|  |       " | ||||||
|  |     > | ||||||
|       <BaseFormatMoney :amount="tax.amount" :currency="currency" /> |       <BaseFormatMoney :amount="tax.amount" :currency="currency" /> | ||||||
|  |  | ||||||
|       <BaseIcon |       <BaseIcon | ||||||
|         name="TrashIcon" |         name="TrashIcon" | ||||||
|         class="h-5 ml-2 cursor-pointer" |         class="h-5 ml-2 cursor-pointer dark:text-red-400" | ||||||
|         @click="$emit('remove', tax.id)" |         @click="$emit('remove', tax.id)" | ||||||
|       /> |       /> | ||||||
|     </label> |     </label> | ||||||
|  | |||||||
| @ -44,7 +44,7 @@ | |||||||
|             > |             > | ||||||
|               <!-- Tax Search Input  --> |               <!-- Tax Search Input  --> | ||||||
|  |  | ||||||
|               <div class="relative bg-white"> |               <div class="relative bg-white dark:bg-gray-800"> | ||||||
|                 <div class="relative p-4"> |                 <div class="relative p-4"> | ||||||
|                   <BaseInput |                   <BaseInput | ||||||
|                     v-model="textSearch" |                     v-model="textSearch" | ||||||
| @ -65,13 +65,14 @@ | |||||||
|                     list |                     list | ||||||
|                     max-h-36 |                     max-h-36 | ||||||
|                     border-t border-gray-200 |                     border-t border-gray-200 | ||||||
|  |                     dark:border-gray-600 | ||||||
|                   " |                   " | ||||||
|                 > |                 > | ||||||
|                   <div |                   <div | ||||||
|                     v-for="(taxType, index) in filteredTaxType" |                     v-for="(taxType, index) in filteredTaxType" | ||||||
|                     :key="index" |                     :key="index" | ||||||
|                     :class="{ |                     :class="{ | ||||||
|                       'bg-gray-100 cursor-not-allowed opacity-50 pointer-events-none': |                       'bg-gray-100 cursor-not-allowed opacity-50 pointer-events-none dark:bg-gray-900': | ||||||
|                         taxes.find((val) => { |                         taxes.find((val) => { | ||||||
|                           return val.tax_type_id === taxType.id |                           return val.tax_type_id === taxType.id | ||||||
|                         }), |                         }), | ||||||
| @ -84,6 +85,7 @@ | |||||||
|                       cursor-pointer |                       cursor-pointer | ||||||
|                       hover:bg-gray-100 hover:cursor-pointer |                       hover:bg-gray-100 hover:cursor-pointer | ||||||
|                       last:border-b-0 |                       last:border-b-0 | ||||||
|  |                       dark:border-gray-600 dark:hover:bg-gray-700/20 | ||||||
|                     " |                     " | ||||||
|                     @click="selectTaxType(taxType, close)" |                     @click="selectTaxType(taxType, close)" | ||||||
|                   > |                   > | ||||||
| @ -96,6 +98,7 @@ | |||||||
|                           leading-tight |                           leading-tight | ||||||
|                           text-gray-700 |                           text-gray-700 | ||||||
|                           cursor-pointer |                           cursor-pointer | ||||||
|  |                           dark:text-gray-300 | ||||||
|                         " |                         " | ||||||
|                       > |                       > | ||||||
|                         {{ taxType.name }} |                         {{ taxType.name }} | ||||||
| @ -108,6 +111,7 @@ | |||||||
|                           font-semibold |                           font-semibold | ||||||
|                           text-gray-700 |                           text-gray-700 | ||||||
|                           cursor-pointer |                           cursor-pointer | ||||||
|  |                           dark:text-gray-300 | ||||||
|                         " |                         " | ||||||
|                       > |                       > | ||||||
|                         {{ taxType.percent }} % |                         {{ taxType.percent }} % | ||||||
| @ -138,6 +142,10 @@ | |||||||
|                   bg-gray-200 |                   bg-gray-200 | ||||||
|                   border-none |                   border-none | ||||||
|                   outline-none |                   outline-none | ||||||
|  |                   dark:bg-gray-600/70 | ||||||
|  |                   dark:backdrop-blur-xl | ||||||
|  |                   dark:shadow-glass | ||||||
|  |                   dark:hover:bg-gray-600/80 | ||||||
|                 " |                 " | ||||||
|                 @click="openTaxTypeModal" |                 @click="openTaxTypeModal" | ||||||
|               > |               > | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| <template> | <template> | ||||||
|   <div> |   <div> | ||||||
|     <label class="flex text-gray-800 font-medium text-sm mb-2"> |     <label class="flex text-gray-800 font-medium text-sm mb-2 dark:text-gray-300"> | ||||||
|       {{ $t('general.select_template') }} |       {{ $t('general.select_template') }} | ||||||
|       <span class="text-sm text-red-500"> *</span> |       <span class="text-sm text-red-500"> *</span> | ||||||
|     </label> |     </label> | ||||||
|  | |||||||
| @ -57,9 +57,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -84,7 +82,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.create') }} |           {{ $t('general.create') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -47,15 +47,7 @@ | |||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           p-4 |  | ||||||
|           border-t border-gray-200 border-solid border-modal-bg |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           type="button" |           type="button" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -80,7 +72,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ categoryStore.isEdit ? $t('general.update') : $t('general.save') }} |           {{ categoryStore.isEdit ? $t('general.update') : $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -48,6 +48,24 @@ | |||||||
|             /> |             /> | ||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|  |  | ||||||
|  |           <BaseInputGroup | ||||||
|  |             :label="$tc('settings.company_info.company_slug')" | ||||||
|  |             :help-text="$t('settings.company_info.company_slug_help_text')" | ||||||
|  |             :error=" | ||||||
|  |               v$.newCompanyForm.slug.$error && | ||||||
|  |               v$.newCompanyForm.slug.$errors[0].$message | ||||||
|  |             " | ||||||
|  |             :content-loading="isFetchingInitialData" | ||||||
|  |             required | ||||||
|  |           > | ||||||
|  |             <BaseInput | ||||||
|  |               v-model="newCompanyForm.slug" | ||||||
|  |               :invalid="v$.newCompanyForm.slug.$error" | ||||||
|  |               :content-loading="isFetchingInitialData" | ||||||
|  |               @input="v$.newCompanyForm.slug.$touch()" | ||||||
|  |             /> | ||||||
|  |           </BaseInputGroup> | ||||||
|  |  | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
|             :content-loading="isFetchingInitialData" |             :content-loading="isFetchingInitialData" | ||||||
|             :label="$tc('settings.company_info.country')" |             :label="$tc('settings.company_info.country')" | ||||||
| @ -98,7 +116,7 @@ | |||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div class="z-0 flex justify-end p-4 bg-gray-50 border-modal-bg"> |        <BaseModalFooter> | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3 text-sm" |           class="mr-3 text-sm" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -123,14 +141,14 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.save') }} |           {{ $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script setup> | <script setup> | ||||||
| import { useModalStore } from '@/scripts/stores/modal' | import { useModalStore } from '@/scripts/stores/modal' | ||||||
| import { computed, onMounted, ref, reactive } from 'vue' | import { computed, onMounted, ref, reactive, watch } from 'vue' | ||||||
| import { useI18n } from 'vue-i18n' | import { useI18n } from 'vue-i18n' | ||||||
| import { required, minLength, helpers } from '@vuelidate/validators' | import { required, minLength, helpers } from '@vuelidate/validators' | ||||||
| import { useVuelidate } from '@vuelidate/core' | import { useVuelidate } from '@vuelidate/core' | ||||||
| @ -152,6 +170,7 @@ let companyLogoName = ref(null) | |||||||
|  |  | ||||||
| const newCompanyForm = reactive({ | const newCompanyForm = reactive({ | ||||||
|   name: null, |   name: null, | ||||||
|  |   slug: null, | ||||||
|   currency: '', |   currency: '', | ||||||
|   address: { |   address: { | ||||||
|     country_id: null, |     country_id: null, | ||||||
| @ -162,6 +181,9 @@ const modalActive = computed(() => { | |||||||
|   return modalStore.active && modalStore.componentName === 'CompanyModal' |   return modalStore.active && modalStore.componentName === 'CompanyModal' | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | const slugValidator = (value) => { | ||||||
|  |   return value == slugify(value) | ||||||
|  | } | ||||||
| const rules = { | const rules = { | ||||||
|   newCompanyForm: { |   newCompanyForm: { | ||||||
|     name: { |     name: { | ||||||
| @ -171,6 +193,17 @@ const rules = { | |||||||
|         minLength(3) |         minLength(3) | ||||||
|       ), |       ), | ||||||
|     }, |     }, | ||||||
|  |     slug: { | ||||||
|  |       required: helpers.withMessage(t('validation.required'), required), | ||||||
|  |       minLength: helpers.withMessage( | ||||||
|  |         t('validation.name_min_length', { count: 3 }), | ||||||
|  |         minLength(3) | ||||||
|  |       ), | ||||||
|  |       slugValidator: helpers.withMessage( | ||||||
|  |         t('validation.invalid_slug'), | ||||||
|  |         slugValidator | ||||||
|  |       ), | ||||||
|  |     }, | ||||||
|     address: { |     address: { | ||||||
|       country_id: { |       country_id: { | ||||||
|         required: helpers.withMessage(t('validation.required'), required), |         required: helpers.withMessage(t('validation.required'), required), | ||||||
| @ -243,6 +276,7 @@ async function submitCompanyData() { | |||||||
|  |  | ||||||
| function resetNewCompanyForm() { | function resetNewCompanyForm() { | ||||||
|   newCompanyForm.name = '' |   newCompanyForm.name = '' | ||||||
|  |   newCompanyForm.slug = '' | ||||||
|   newCompanyForm.currency = '' |   newCompanyForm.currency = '' | ||||||
|   newCompanyForm.address.country_id = '' |   newCompanyForm.address.country_id = '' | ||||||
|  |  | ||||||
| @ -257,4 +291,24 @@ function closeCompanyModal() { | |||||||
|     v$.value.$reset() |     v$.value.$reset() | ||||||
|   }, 300) |   }, 300) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // watcher for if change company name then auto fill company slug value | ||||||
|  | watch( | ||||||
|  |   () => newCompanyForm.name, | ||||||
|  |   (currentValue) => { | ||||||
|  |     newCompanyForm.slug = slugify(currentValue) | ||||||
|  |   } | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | function slugify(string) { | ||||||
|  |   return string | ||||||
|  |     .toString() | ||||||
|  |     .trim() | ||||||
|  |     .toLowerCase() | ||||||
|  |     .replace(/\s+/g, '-') | ||||||
|  |     .replace(/[^\w\-]+/g, '') | ||||||
|  |     .replace(/\-\-+/g, '-') | ||||||
|  |     .replace(/^-+/, '') | ||||||
|  |     .replace(/-+$/, '') | ||||||
|  | } | ||||||
| </script> | </script> | ||||||
|  | |||||||
| @ -122,7 +122,7 @@ | |||||||
|           <BaseTab :title="$t('customers.portal_access')"> |           <BaseTab :title="$t('customers.portal_access')"> | ||||||
|             <BaseInputGrid class="col-span-5 lg:col-span-4"> |             <BaseInputGrid class="col-span-5 lg:col-span-4"> | ||||||
|               <div class="md:col-span-2"> |               <div class="md:col-span-2"> | ||||||
|                 <p class="text-sm text-gray-500"> |                 <p class="text-sm text-gray-500 dark:text-gray-300"> | ||||||
|                   {{ $t('customers.portal_access_text') }} |                   {{ $t('customers.portal_access_text') }} | ||||||
|                 </p> |                 </p> | ||||||
|  |  | ||||||
| @ -425,9 +425,7 @@ | |||||||
|         </BaseTabGroup> |         </BaseTabGroup> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3 text-sm" |           class="mr-3 text-sm" | ||||||
|           type="button" |           type="button" | ||||||
| @ -447,13 +445,13 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.save') }} |           {{ $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script setup> | <script setup> | ||||||
| import { computed, ref } from 'vue' | import { computed, onMounted, ref } from 'vue' | ||||||
| import { useRoute } from 'vue-router' | import { useRoute } from 'vue-router' | ||||||
| import { useI18n } from 'vue-i18n' | import { useI18n } from 'vue-i18n' | ||||||
|  |  | ||||||
| @ -549,6 +547,7 @@ const rules = computed(() => { | |||||||
|     website: { |     website: { | ||||||
|       url: helpers.withMessage(t('validation.invalid_url'), url), |       url: helpers.withMessage(t('validation.invalid_url'), url), | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     billing: { |     billing: { | ||||||
|       address_street_1: { |       address_street_1: { | ||||||
|         maxLength: helpers.withMessage( |         maxLength: helpers.withMessage( | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ | |||||||
|         </BaseInputGroup> |         </BaseInputGroup> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div class="z-0 flex justify-end p-4 bg-gray-50 border-modal-bg"> |       <BaseModalFooter> | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3 text-sm" |           class="mr-3 text-sm" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -63,7 +63,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.delete') }} |           {{ $t('general.delete') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -150,9 +150,7 @@ | |||||||
|           @Remove="removeUsedSelectedCurrencies" |           @Remove="removeUsedSelectedCurrencies" | ||||||
|         /> |         /> | ||||||
|       </div> |       </div> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -179,7 +177,7 @@ | |||||||
|             exchangeRateStore.isEdit ? $t('general.update') : $t('general.save') |             exchangeRateStore.isEdit ? $t('general.update') : $t('general.save') | ||||||
|           }} |           }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -20,15 +20,7 @@ | |||||||
|         @submit="createNewDisk" |         @submit="createNewDisk" | ||||||
|       > |       > | ||||||
|         <template #default="slotProps"> |         <template #default="slotProps"> | ||||||
|           <div |           <BaseModalFooter> | ||||||
|             class=" |  | ||||||
|               z-0 |  | ||||||
|               flex |  | ||||||
|               justify-end |  | ||||||
|               p-4 |  | ||||||
|               border-t border-solid border-gray-light |  | ||||||
|             " |  | ||||||
|           > |  | ||||||
|             <BaseButton |             <BaseButton | ||||||
|               class="mr-3 text-sm" |               class="mr-3 text-sm" | ||||||
|               variant="primary-outline" |               variant="primary-outline" | ||||||
| @ -52,7 +44,7 @@ | |||||||
|  |  | ||||||
|               {{ $t('general.save') }} |               {{ $t('general.save') }} | ||||||
|             </BaseButton> |             </BaseButton> | ||||||
|           </div> |           </BaseModalFooter> | ||||||
|         </template> |         </template> | ||||||
|       </component> |       </component> | ||||||
|     </div> |     </div> | ||||||
|  | |||||||
| @ -89,9 +89,7 @@ | |||||||
|             </BaseInputGroup> |             </BaseInputGroup> | ||||||
|           </BaseInputGrid> |           </BaseInputGrid> | ||||||
|         </div> |         </div> | ||||||
|         <div |         <BaseModalFooter> | ||||||
|           class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|         > |  | ||||||
|           <BaseButton |           <BaseButton | ||||||
|             class="mr-3" |             class="mr-3" | ||||||
|             variant="primary-outline" |             variant="primary-outline" | ||||||
| @ -111,7 +109,7 @@ | |||||||
|             </template> |             </template> | ||||||
|             {{ itemStore.isEdit ? $t('general.update') : $t('general.save') }} |             {{ itemStore.isEdit ? $t('general.update') : $t('general.save') }} | ||||||
|           </BaseButton> |           </BaseButton> | ||||||
|         </div> |         </BaseModalFooter> | ||||||
|       </form> |       </form> | ||||||
|     </div> |     </div> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
|  | |||||||
| @ -31,15 +31,7 @@ | |||||||
|         </BaseInputGroup> |         </BaseInputGroup> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           p-4 |  | ||||||
|           border-t border-gray-200 border-solid border-modal-bg |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           type="button" |           type="button" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -66,7 +58,7 @@ | |||||||
|             itemStore.isItemUnitEdit ? $t('general.update') : $t('general.save') |             itemStore.isItemUnitEdit ? $t('general.update') : $t('general.save') | ||||||
|           }} |           }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -1,287 +0,0 @@ | |||||||
| <template> |  | ||||||
|   <BaseModal |  | ||||||
|     :show="modalStore.active && modalStore.componentName === 'MailSenderModal'" |  | ||||||
|   > |  | ||||||
|     <template #header> |  | ||||||
|       <div class="flex justify-between w-full"> |  | ||||||
|         {{ modalStore.title }} |  | ||||||
|         <BaseIcon |  | ||||||
|           name="XIcon" |  | ||||||
|           class="h-6 w-6 text-gray-500 cursor-pointer" |  | ||||||
|           @click="closeMailSenderModal" |  | ||||||
|         /> |  | ||||||
|       </div> |  | ||||||
|     </template> |  | ||||||
|     <form action="" @submit.prevent="submitMailSenderData"> |  | ||||||
|       <div class="p-4 sm:p-6 my-2"> |  | ||||||
|         <!-- Name --> |  | ||||||
|         <BaseInputGrid> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.name`)" |  | ||||||
|             :error="v$.name.$error && v$.name.$errors[0].$message" |  | ||||||
|             :help-text="$t(`${pre_t}.name_help`)" |  | ||||||
|             required |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model.trim="mailSenderStore.currentMailSender.name" |  | ||||||
|               :invalid="v$.name.$error" |  | ||||||
|               type="text" |  | ||||||
|               @input="v$.name.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <!-- From Name --> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.from_name`)" |  | ||||||
|             :error="v$.from_name.$error && v$.from_name.$errors[0].$message" |  | ||||||
|             required |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model="mailSenderStore.currentMailSender.from_name" |  | ||||||
|               :invalid="v$.from_name.$error" |  | ||||||
|               type="text" |  | ||||||
|               @input="v$.from_name.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <!-- From Address --> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.from_address`)" |  | ||||||
|             :error=" |  | ||||||
|               v$.from_address.$error && v$.from_address.$errors[0].$message |  | ||||||
|             " |  | ||||||
|             required |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model="mailSenderStore.currentMailSender.from_address" |  | ||||||
|               :invalid="v$.from_address.$error" |  | ||||||
|               type="text" |  | ||||||
|               @input="v$.from_address.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <!-- CC --> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.cc`)" |  | ||||||
|             :error="v$.cc.$error && v$.cc.$errors[0].$message" |  | ||||||
|             :help-text="$t(`${pre_t}.email_list`)" |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model="mailSenderStore.currentMailSender.cc" |  | ||||||
|               :invalid="v$.cc.$error" |  | ||||||
|               type="text" |  | ||||||
|               @input="v$.cc.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <!-- BCC --> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.bcc`)" |  | ||||||
|             :error="v$.bcc.$error && v$.bcc.$errors[0].$message" |  | ||||||
|             :help-text="$t(`${pre_t}.email_list`)" |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model="mailSenderStore.currentMailSender.bcc" |  | ||||||
|               :invalid="v$.bcc.$error" |  | ||||||
|               type="text" |  | ||||||
|               @input="v$.bcc.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <!-- Mail Driver --> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.driver`)" |  | ||||||
|             :error="v$.driver.$error && v$.driver.$errors[0].$message" |  | ||||||
|             required |  | ||||||
|           > |  | ||||||
|             <BaseMultiselect |  | ||||||
|               v-model="mailSenderStore.currentMailSender.driver" |  | ||||||
|               :options="mailSenderStore.mail_drivers" |  | ||||||
|               :can-deselect="false" |  | ||||||
|               :invalid="v$.driver.$error" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <component |  | ||||||
|             :is="loadMailDriver" |  | ||||||
|             :mail-sender-store="mailSenderStore" |  | ||||||
|           /> |  | ||||||
|         </BaseInputGrid> |  | ||||||
|  |  | ||||||
|         <BaseDivider class="mt-4 mb-0" /> |  | ||||||
|  |  | ||||||
|         <!-- Is Default? --> |  | ||||||
|         <BaseSwitchSection |  | ||||||
|           v-if="!mailSenderStore.isDisable" |  | ||||||
|           v-model="mailSenderStore.currentMailSender.is_default" |  | ||||||
|           :title="$t(`${pre_t}.is_default`)" |  | ||||||
|           :description="$t(`${pre_t}.is_default_description`)" |  | ||||||
|         /> |  | ||||||
|       </div> |  | ||||||
|  |  | ||||||
|       <div |  | ||||||
|         class="z-0 flex justify-end p-4 border-t border-solid border--200 border-modal-bg" |  | ||||||
|       > |  | ||||||
|         <BaseButton |  | ||||||
|           class="mr-3 text-sm" |  | ||||||
|           variant="primary-outline" |  | ||||||
|           type="button" |  | ||||||
|           @click="closeMailSenderModal" |  | ||||||
|         > |  | ||||||
|           {{ $t('general.cancel') }} |  | ||||||
|         </BaseButton> |  | ||||||
|         <BaseButton |  | ||||||
|           :loading="isSaving" |  | ||||||
|           :disabled="isSaving" |  | ||||||
|           variant="primary" |  | ||||||
|           type="submit" |  | ||||||
|         > |  | ||||||
|           <template #left="slotProps"> |  | ||||||
|             <BaseIcon |  | ||||||
|               v-if="!isSaving" |  | ||||||
|               name="SaveIcon" |  | ||||||
|               :class="slotProps.class" |  | ||||||
|             /> |  | ||||||
|           </template> |  | ||||||
|           {{ |  | ||||||
|             mailSenderStore.isEdit ? $t('general.update') : $t('general.save') |  | ||||||
|           }} |  | ||||||
|         </BaseButton> |  | ||||||
|       </div> |  | ||||||
|     </form> |  | ||||||
|   </BaseModal> |  | ||||||
| </template> |  | ||||||
|  |  | ||||||
| <script setup> |  | ||||||
| import { computed, onMounted, ref } from 'vue' |  | ||||||
| import { useI18n } from 'vue-i18n' |  | ||||||
| import { required, email, minLength, helpers } from '@vuelidate/validators' |  | ||||||
| import { useVuelidate } from '@vuelidate/core' |  | ||||||
| import { useModalStore } from '@/scripts/stores/modal' |  | ||||||
| import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender' |  | ||||||
| import SmtpDriver from '@/scripts/admin/views/settings/mail-sender/SmtpDriver.vue' |  | ||||||
| import MailgunDriver from '@/scripts/admin/views/settings/mail-sender/MailgunDriver.vue' |  | ||||||
| import SesDriver from '@/scripts/admin/views/settings/mail-sender/SesDriver.vue' |  | ||||||
|  |  | ||||||
| const pre_t = 'settings.mail_sender' |  | ||||||
| const modalStore = useModalStore() |  | ||||||
| const mailSenderStore = useMailSenderStore() |  | ||||||
| const { t } = useI18n() |  | ||||||
| let isSaving = ref(false) |  | ||||||
|  |  | ||||||
| const loadMailDriver = computed(() => { |  | ||||||
|   switch (mailSenderStore.currentMailSender.driver) { |  | ||||||
|     case 'smtp': |  | ||||||
|       return SmtpDriver |  | ||||||
|     case 'mail': |  | ||||||
|       return false |  | ||||||
|     case 'sendmail': |  | ||||||
|       return false |  | ||||||
|     case 'mailgun': |  | ||||||
|       return MailgunDriver |  | ||||||
|     case 'ses': |  | ||||||
|       return SesDriver |  | ||||||
|     default: |  | ||||||
|       return false |  | ||||||
|   } |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| // This is multiple email custom validation |  | ||||||
| const multiEmail = (value) => { |  | ||||||
|   if (value == '' || value === null) return true |  | ||||||
|   const emailRegex = |  | ||||||
|     /^(?:[A-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9]{2,}(?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i |  | ||||||
|  |  | ||||||
|   const emailArr = value.split(',') |  | ||||||
|   let isValid = emailArr.every((v) => { |  | ||||||
|     return emailRegex.test(v) |  | ||||||
|   }) |  | ||||||
|   return isValid |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const rules = computed(() => { |  | ||||||
|   return { |  | ||||||
|     name: { |  | ||||||
|       required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|       minLength: helpers.withMessage( |  | ||||||
|         t('validation.name_min_length', { count: 3 }), |  | ||||||
|         minLength(3) |  | ||||||
|       ), |  | ||||||
|     }, |  | ||||||
|     from_name: { |  | ||||||
|       required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|     }, |  | ||||||
|     from_address: { |  | ||||||
|       required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|       email: helpers.withMessage(t('validation.email_incorrect'), email), |  | ||||||
|     }, |  | ||||||
|     cc: { |  | ||||||
|       multiEmail: helpers.withMessage( |  | ||||||
|         t('validation.email_incorrect'), |  | ||||||
|         multiEmail |  | ||||||
|       ), |  | ||||||
|     }, |  | ||||||
|     bcc: { |  | ||||||
|       multiEmail: helpers.withMessage( |  | ||||||
|         t('validation.email_incorrect'), |  | ||||||
|         multiEmail |  | ||||||
|       ), |  | ||||||
|     }, |  | ||||||
|     driver: { |  | ||||||
|       required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|     }, |  | ||||||
|   } |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| const v$ = useVuelidate( |  | ||||||
|   rules, |  | ||||||
|   computed(() => mailSenderStore.currentMailSender) |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| async function submitMailSenderData() { |  | ||||||
|   v$.value.$touch() |  | ||||||
|   if (v$.value.$invalid) { |  | ||||||
|     return true |  | ||||||
|   } |  | ||||||
|   try { |  | ||||||
|     const action = mailSenderStore.isEdit |  | ||||||
|       ? mailSenderStore.updateMailSender |  | ||||||
|       : mailSenderStore.addMailSender |  | ||||||
|     isSaving.value = true |  | ||||||
|  |  | ||||||
|     var mailDriverConfig = null |  | ||||||
|     switch (mailSenderStore.currentMailSender.driver) { |  | ||||||
|       case 'smtp': |  | ||||||
|         mailDriverConfig = mailSenderStore.smtpConfig |  | ||||||
|         break |  | ||||||
|       case 'mailgun': |  | ||||||
|         mailDriverConfig = mailSenderStore.mailgunConfig |  | ||||||
|         break |  | ||||||
|       case 'ses': |  | ||||||
|         mailDriverConfig = mailSenderStore.sesConfig |  | ||||||
|         break |  | ||||||
|     } |  | ||||||
|     mailSenderStore.currentMailSender.settings = mailDriverConfig |  | ||||||
|  |  | ||||||
|     let res = await action(mailSenderStore.currentMailSender) |  | ||||||
|     isSaving.value = false |  | ||||||
|     modalStore.refreshData ? modalStore.refreshData(res.data.data) : '' |  | ||||||
|     closeMailSenderModal() |  | ||||||
|   } catch (err) { |  | ||||||
|     isSaving.value = false |  | ||||||
|     return true |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| function closeMailSenderModal() { |  | ||||||
|   modalStore.closeModal() |  | ||||||
|   setTimeout(() => { |  | ||||||
|     mailSenderStore.resetCurrentMailSender() |  | ||||||
|     v$.value.$reset() |  | ||||||
|   }, 300) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| onMounted(async () => { |  | ||||||
|   await mailSenderStore.fetchMailDrivers() |  | ||||||
| }) |  | ||||||
| </script> |  | ||||||
| @ -1,208 +0,0 @@ | |||||||
| <template> |  | ||||||
|   <BaseModal :show="modalActive" @open="setInitialData"> |  | ||||||
|     <template #header> |  | ||||||
|       <div class="flex justify-between w-full"> |  | ||||||
|         {{ modalStore.title }} |  | ||||||
|         <BaseIcon |  | ||||||
|           name="XIcon" |  | ||||||
|           class="w-6 h-6 text-gray-500 cursor-pointer" |  | ||||||
|           @click="closeTestModal" |  | ||||||
|         /> |  | ||||||
|       </div> |  | ||||||
|     </template> |  | ||||||
|     <form action="" @submit.prevent="onTestMailSend"> |  | ||||||
|       <div class="p-4 md:p-8"> |  | ||||||
|         <BaseInputGrid layout="one-column"> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t(`${pre_t}.title`)" |  | ||||||
|             variant="horizontal" |  | ||||||
|             :content-loading="isFetchingInitialData" |  | ||||||
|             :error=" |  | ||||||
|               v$.mail_sender_id.$error && v$.mail_sender_id.$errors[0].$message |  | ||||||
|             " |  | ||||||
|           > |  | ||||||
|             <BaseMultiselect |  | ||||||
|               v-model="formData.mail_sender_id" |  | ||||||
|               :invalid="v$.mail_sender_id.$error" |  | ||||||
|               label="name" |  | ||||||
|               :options="mailSenderStore.mailSenders" |  | ||||||
|               value-prop="id" |  | ||||||
|               :can-deselect="false" |  | ||||||
|               :can-clear="false" |  | ||||||
|               :placeholder="$t(`${pre_t}.select_mail_sender`)" |  | ||||||
|               searchable |  | ||||||
|               track-by="name" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|  |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t('general.to')" |  | ||||||
|             :error="v$.to.$error && v$.to.$errors[0].$message" |  | ||||||
|             variant="horizontal" |  | ||||||
|             required |  | ||||||
|             :content-loading="isFetchingInitialData" |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model="formData.to" |  | ||||||
|               type="text" |  | ||||||
|               :invalid="v$.to.$error" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|               @input="v$.to.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t('general.subject')" |  | ||||||
|             :error="v$.subject.$error && v$.subject.$errors[0].$message" |  | ||||||
|             variant="horizontal" |  | ||||||
|             required |  | ||||||
|             :content-loading="isFetchingInitialData" |  | ||||||
|           > |  | ||||||
|             <BaseInput |  | ||||||
|               v-model="formData.subject" |  | ||||||
|               type="text" |  | ||||||
|               :invalid="v$.subject.$error" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|               @input="v$.subject.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|           <BaseInputGroup |  | ||||||
|             :label="$t('general.message')" |  | ||||||
|             :error="v$.message.$error && v$.message.$errors[0].$message" |  | ||||||
|             variant="horizontal" |  | ||||||
|             required |  | ||||||
|             :content-loading="isFetchingInitialData" |  | ||||||
|           > |  | ||||||
|             <BaseTextarea |  | ||||||
|               v-model="formData.message" |  | ||||||
|               rows="4" |  | ||||||
|               cols="50" |  | ||||||
|               :invalid="v$.message.$error" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|               @input="v$.message.$touch()" |  | ||||||
|             /> |  | ||||||
|           </BaseInputGroup> |  | ||||||
|         </BaseInputGrid> |  | ||||||
|       </div> |  | ||||||
|       <div |  | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |  | ||||||
|           variant="primary-outline" |  | ||||||
|           type="button" |  | ||||||
|           class="mr-3" |  | ||||||
|           :content-loading="isFetchingInitialData" |  | ||||||
|           @click="closeTestModal()" |  | ||||||
|         > |  | ||||||
|           {{ $t('general.cancel') }} |  | ||||||
|         </BaseButton> |  | ||||||
|  |  | ||||||
|         <BaseButton |  | ||||||
|           :loading="isSaving" |  | ||||||
|           variant="primary" |  | ||||||
|           type="submit" |  | ||||||
|           :content-loading="isFetchingInitialData" |  | ||||||
|         > |  | ||||||
|           <template #left="slotProps"> |  | ||||||
|             <BaseIcon |  | ||||||
|               v-if="!isSaving" |  | ||||||
|               name="PaperAirplaneIcon" |  | ||||||
|               :class="slotProps.class" |  | ||||||
|             /> |  | ||||||
|           </template> |  | ||||||
|           {{ $t('general.send') }} |  | ||||||
|         </BaseButton> |  | ||||||
|       </div> |  | ||||||
|     </form> |  | ||||||
|   </BaseModal> |  | ||||||
| </template> |  | ||||||
|  |  | ||||||
| <script setup> |  | ||||||
| import { reactive, ref, computed } from 'vue' |  | ||||||
| import { useI18n } from 'vue-i18n' |  | ||||||
| import { required, email, maxLength, helpers } from '@vuelidate/validators' |  | ||||||
| import useVuelidate from '@vuelidate/core' |  | ||||||
| import { useModalStore } from '@/scripts/stores/modal' |  | ||||||
| import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender' |  | ||||||
|  |  | ||||||
| const pre_t = 'settings.mail_sender' |  | ||||||
| const modalStore = useModalStore() |  | ||||||
| const mailSenderStore = useMailSenderStore() |  | ||||||
| const { t } = useI18n() |  | ||||||
| let isSaving = ref(false) |  | ||||||
| let formData = reactive({ |  | ||||||
|   mail_sender_id: '', |  | ||||||
|   to: '', |  | ||||||
|   subject: '', |  | ||||||
|   message: '', |  | ||||||
| }) |  | ||||||
| const isFetchingInitialData = ref(false) |  | ||||||
|  |  | ||||||
| const modalActive = computed(() => { |  | ||||||
|   return modalStore.active && modalStore.componentName === 'MailSenderTestModal' |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| function setInitialData() { |  | ||||||
|   isFetchingInitialData.value = true |  | ||||||
|   formData.mail_sender_id = modalStore.id |  | ||||||
|   setTimeout(() => { |  | ||||||
|     isFetchingInitialData.value = false |  | ||||||
|   }, 100) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const rules = { |  | ||||||
|   mail_sender_id: { |  | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|   }, |  | ||||||
|   to: { |  | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|     email: helpers.withMessage(t('validation.email_incorrect'), email), |  | ||||||
|   }, |  | ||||||
|   subject: { |  | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|     maxLength: helpers.withMessage( |  | ||||||
|       t('validation.subject_maxlength'), |  | ||||||
|       maxLength(100) |  | ||||||
|     ), |  | ||||||
|   }, |  | ||||||
|   message: { |  | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |  | ||||||
|     maxLength: helpers.withMessage( |  | ||||||
|       t('validation.message_maxlength'), |  | ||||||
|       maxLength(255) |  | ||||||
|     ), |  | ||||||
|   }, |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const v$ = useVuelidate(rules, formData) |  | ||||||
|  |  | ||||||
| function resetFormData() { |  | ||||||
|   formData.mail_sender_id = '' |  | ||||||
|   formData.to = '' |  | ||||||
|   formData.subject = '' |  | ||||||
|   formData.message = '' |  | ||||||
|  |  | ||||||
|   v$.value.$reset() |  | ||||||
| } |  | ||||||
|  |  | ||||||
| async function onTestMailSend() { |  | ||||||
|   v$.value.$touch() |  | ||||||
|   if (v$.value.$invalid) { |  | ||||||
|     return true |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   isSaving.value = true |  | ||||||
|   let response = await mailSenderStore.sendTestMail(formData) |  | ||||||
|   if (response.data) { |  | ||||||
|     closeTestModal() |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| function closeTestModal() { |  | ||||||
|   modalStore.closeModal() |  | ||||||
|   setTimeout(() => { |  | ||||||
|     isSaving.value = false |  | ||||||
|     modalStore.resetModalData() |  | ||||||
|     resetFormData() |  | ||||||
|   }, 300) |  | ||||||
| } |  | ||||||
| </script> |  | ||||||
| @ -62,9 +62,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <div |      <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
|           type="button" |           type="button" | ||||||
| @ -84,7 +82,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.send') }} |           {{ $t('general.send') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -63,16 +63,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <div |      <BaseModalFooter> | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           px-4 |  | ||||||
|           py-4 |  | ||||||
|           border-t border-solid border-gray-light |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-2" |           class="mr-2" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -93,7 +84,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ noteStore.isEdit ? $t('general.update') : $t('general.save') }} |           {{ noteStore.isEdit ? $t('general.update') : $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -29,9 +29,7 @@ | |||||||
|         </BaseInputGroup> |         </BaseInputGroup> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
| @ -56,7 +54,7 @@ | |||||||
|               : $t('general.save') |               : $t('general.save') | ||||||
|           }} |           }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -40,6 +40,7 @@ | |||||||
|             px-4 |             px-4 | ||||||
|             md:px-8 |             md:px-8 | ||||||
|             py-1.5 |             py-1.5 | ||||||
|  |             dark:text-gray-200 | ||||||
|           " |           " | ||||||
|         > |         > | ||||||
|           {{ $tc('settings.roles.permission', 2) }} |           {{ $tc('settings.roles.permission', 2) }} | ||||||
| @ -72,7 +73,7 @@ | |||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div class="border-t border-gray-200 py-3"> |       <div class="border-t border-gray-200 dark:border-gray-600 py-3"> | ||||||
|         <div |         <div | ||||||
|           class=" |           class=" | ||||||
|             grid grid-cols-1 |             grid grid-cols-1 | ||||||
| @ -89,7 +90,7 @@ | |||||||
|             :key="gIndex" |             :key="gIndex" | ||||||
|             class="flex flex-col space-y-1" |             class="flex flex-col space-y-1" | ||||||
|           > |           > | ||||||
|             <p class="text-sm text-gray-500 border-b border-gray-200 pb-1 mb-2"> |             <p class="text-sm text-gray-500 dark:text-gray-200 border-b dark:border-gray-600 pb-1 mb-2"> | ||||||
|               {{ gIndex }} |               {{ gIndex }} | ||||||
|             </p> |             </p> | ||||||
|             <div |             <div | ||||||
| @ -116,15 +117,7 @@ | |||||||
|           </span> |           </span> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           p-4 |  | ||||||
|           border-t border-solid border--200 border-modal-bg |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3 text-sm" |           class="mr-3 text-sm" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -144,7 +137,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ !roleStore.isEdit ? $t('general.save') : $t('general.update') }} |           {{ !roleStore.isEdit ? $t('general.save') : $t('general.update') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -70,7 +70,7 @@ | |||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <div class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid"> |     <BaseModalFooter> | ||||||
|       <BaseButton class="mr-3" variant="primary-outline" @click="closeModal"> |       <BaseButton class="mr-3" variant="primary-outline" @click="closeModal"> | ||||||
|         {{ $t('general.cancel') }} |         {{ $t('general.cancel') }} | ||||||
|       </BaseButton> |       </BaseButton> | ||||||
| @ -80,7 +80,7 @@ | |||||||
|         </template> |         </template> | ||||||
|         {{ $t('general.choose') }} |         {{ $t('general.choose') }} | ||||||
|       </BaseButton> |       </BaseButton> | ||||||
|     </div> |     </BaseModalFooter> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  |  | ||||||
|  | |||||||
| @ -16,28 +16,18 @@ | |||||||
|     </template> |     </template> | ||||||
|  |  | ||||||
|     <form v-if="!isPreview" action=""> |     <form v-if="!isPreview" action=""> | ||||||
|       <!-- v-if --> |       <div class="px-8 py-8 sm:p-6"> | ||||||
|       <div v-if="isMailSenderExist" class="px-8 py-8 sm:p-6"> |  | ||||||
|         <BaseInputGrid layout="one-column"> |         <BaseInputGrid layout="one-column"> | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
|             :label="$tc('settings.mail_sender.title', 1)" |             :label="$t('general.from')" | ||||||
|             required |             required | ||||||
|             :error=" |             :error="v$.from.$error && v$.from.$errors[0].$message" | ||||||
|               v$.mail_sender_id.$error && v$.mail_sender_id.$errors[0].$message |  | ||||||
|             " |  | ||||||
|           > |           > | ||||||
|             <BaseMultiselect |             <BaseInput | ||||||
|               v-model="estimateMailForm.mail_sender_id" |               v-model="estimateMailForm.from" | ||||||
|               :invalid="v$.mail_sender_id.$error" |               type="text" | ||||||
|               label="name" |               :invalid="v$.from.$error" | ||||||
|               :options="mailSenders" |               @input="v$.from.$touch()" | ||||||
|               value-prop="id" |  | ||||||
|               :can-deselect="false" |  | ||||||
|               :can-clear="false" |  | ||||||
|               :placeholder="$t(`settings.mail_sender.select_mail_sender`)" |  | ||||||
|               searchable |  | ||||||
|               track-by="name" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|             /> |             /> | ||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
| @ -72,48 +62,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <!-- v-else --> |       <BaseModalFooter> | ||||||
|       <div v-else-if="!isMailSenderExist && !isFetchingInitialData"> |  | ||||||
|         <FeedbackAlert |  | ||||||
|           :title="$t('settings.mail_sender.no_mail_sender_found')" |  | ||||||
|           :description=" |  | ||||||
|             $t('settings.mail_sender.no_mail_sender_found_description') |  | ||||||
|           " |  | ||||||
|           type="warning" |  | ||||||
|         > |  | ||||||
|           <template #action> |  | ||||||
|             <div class="mt-4"> |  | ||||||
|               <div class="-mx-2 -my-1.5 flex"> |  | ||||||
|                 <button |  | ||||||
|                   type="button" |  | ||||||
|                   class=" |  | ||||||
|                     bg-yellow-50 |  | ||||||
|                     px-2 |  | ||||||
|                     py-1.5 |  | ||||||
|                     rounded-md |  | ||||||
|                     text-sm |  | ||||||
|                     font-medium |  | ||||||
|                     text-yellow-800 |  | ||||||
|                     hover:bg-yellow-100 |  | ||||||
|                     focus:outline-none |  | ||||||
|                     focus:ring-2 |  | ||||||
|                     focus:ring-offset-2 |  | ||||||
|                     focus:ring-offset-yellow-50 |  | ||||||
|                     focus:ring-yellow-600 |  | ||||||
|                   " |  | ||||||
|                   @click="gotoMailSender" |  | ||||||
|                 > |  | ||||||
|                   {{ $t('settings.mail_sender.manage_mail_sender') }} |  | ||||||
|                 </button> |  | ||||||
|               </div> |  | ||||||
|             </div> |  | ||||||
|           </template> |  | ||||||
|         </FeedbackAlert> |  | ||||||
|       </div> |  | ||||||
|       <!-- end v-if-else --> |  | ||||||
|       <div |  | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -124,7 +73,6 @@ | |||||||
|         </BaseButton> |         </BaseButton> | ||||||
|  |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           v-if="isMailSenderExist" |  | ||||||
|           :loading="isLoading" |           :loading="isLoading" | ||||||
|           :disabled="isLoading" |           :disabled="isLoading" | ||||||
|           variant="primary" |           variant="primary" | ||||||
| @ -135,7 +83,7 @@ | |||||||
|           <BaseIcon v-if="!isLoading" name="PhotographIcon" class="h-5 mr-2" /> |           <BaseIcon v-if="!isLoading" name="PhotographIcon" class="h-5 mr-2" /> | ||||||
|           {{ $t('general.preview') }} |           {{ $t('general.preview') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|     <div v-else> |     <div v-else> | ||||||
|       <div class="my-6 mx-4 border border-gray-200 relative"> |       <div class="my-6 mx-4 border border-gray-200 relative"> | ||||||
| @ -156,9 +104,7 @@ | |||||||
|         ></iframe> |         ></iframe> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -177,7 +123,7 @@ | |||||||
|           <BaseIcon v-if="!isLoading" name="PaperAirplaneIcon" class="mr-2" /> |           <BaseIcon v-if="!isLoading" name="PaperAirplaneIcon" class="mr-2" /> | ||||||
|           {{ $t('general.send') }} |           {{ $t('general.send') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </div> |     </div> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
| @ -191,24 +137,18 @@ import { useModalStore } from '@/scripts/stores/modal' | |||||||
| import { useEstimateStore } from '@/scripts/admin/stores/estimate' | import { useEstimateStore } from '@/scripts/admin/stores/estimate' | ||||||
| import { useNotificationStore } from '@/scripts/stores/notification' | import { useNotificationStore } from '@/scripts/stores/notification' | ||||||
| import { useCompanyStore } from '@/scripts/admin/stores/company' | import { useCompanyStore } from '@/scripts/admin/stores/company' | ||||||
| import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender' | import { useMailDriverStore } from '@/scripts/admin/stores/mail-driver' | ||||||
| import FeedbackAlert from '@/scripts/admin/components/FeedbackAlert.vue' |  | ||||||
| import { useRouter } from 'vue-router' |  | ||||||
|  |  | ||||||
| const modalStore = useModalStore() | const modalStore = useModalStore() | ||||||
| const estimateStore = useEstimateStore() | const estimateStore = useEstimateStore() | ||||||
| const notificationStore = useNotificationStore() | const notificationStore = useNotificationStore() | ||||||
| const companyStore = useCompanyStore() | const companyStore = useCompanyStore() | ||||||
| const mailSenderStore = useMailSenderStore() | const mailDriverStore = useMailDriverStore() | ||||||
| const router = useRouter() |  | ||||||
|  |  | ||||||
| const { t } = useI18n() | const { t } = useI18n() | ||||||
| const isLoading = ref(false) | const isLoading = ref(false) | ||||||
| const templateUrl = ref('') | const templateUrl = ref('') | ||||||
| const isPreview = ref(false) | const isPreview = ref(false) | ||||||
| const mailSenders = ref(null) |  | ||||||
| const isFetchingInitialData = ref(false) |  | ||||||
| const emailTemplates = ref(null) |  | ||||||
|  |  | ||||||
| const estimateMailFields = ref([ | const estimateMailFields = ref([ | ||||||
|   'customer', |   'customer', | ||||||
| @ -220,7 +160,7 @@ const estimateMailFields = ref([ | |||||||
|  |  | ||||||
| let estimateMailForm = reactive({ | let estimateMailForm = reactive({ | ||||||
|   id: null, |   id: null, | ||||||
|   mail_sender_id: null, |   from: null, | ||||||
|   to: null, |   to: null, | ||||||
|   subject: 'New Estimate', |   subject: 'New Estimate', | ||||||
|   body: null, |   body: null, | ||||||
| @ -237,8 +177,9 @@ const modalData = computed(() => { | |||||||
| }) | }) | ||||||
|  |  | ||||||
| const rules = { | const rules = { | ||||||
|   mail_sender_id: { |   from: { | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |     required: helpers.withMessage(t('validation.required'), required), | ||||||
|  |     email: helpers.withMessage(t('validation.email_incorrect'), email), | ||||||
|   }, |   }, | ||||||
|   to: { |   to: { | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |     required: helpers.withMessage(t('validation.required'), required), | ||||||
| @ -262,26 +203,20 @@ function cancelPreview() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function setInitialData() { | async function setInitialData() { | ||||||
|  |   let admin = await companyStore.fetchBasicMailConfig() | ||||||
|  |  | ||||||
|   estimateMailForm.id = modalStore.id |   estimateMailForm.id = modalStore.id | ||||||
|  |  | ||||||
|  |   if (admin.data) { | ||||||
|  |     estimateMailForm.from = admin.data.from_mail | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (modalData.value) { |   if (modalData.value) { | ||||||
|     estimateMailForm.to = modalData.value.customer.email |     estimateMailForm.to = modalData.value.customer.email | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   estimateMailForm.body = |   estimateMailForm.body = | ||||||
|     companyStore.selectedCompanySettings.estimate_mail_body |     companyStore.selectedCompanySettings.estimate_mail_body | ||||||
|  |  | ||||||
|   isFetchingInitialData.value = true |  | ||||||
|   let mailSenderData = await mailSenderStore.fetchMailSenders({ limit: 'all' }) |  | ||||||
|   if (mailSenderData.data) { |  | ||||||
|     mailSenders.value = mailSenderData.data.data |  | ||||||
|     let defaultMailSender = mailSenderData.data.data.find( |  | ||||||
|       (mailSender) => mailSender.is_default == true |  | ||||||
|     ) |  | ||||||
|     estimateMailForm.mail_sender_id = defaultMailSender |  | ||||||
|       ? defaultMailSender.id |  | ||||||
|       : null |  | ||||||
|     isFetchingInitialData.value = false |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| async function submitForm() { | async function submitForm() { | ||||||
| @ -335,18 +270,4 @@ function closeSendEstimateModal() { | |||||||
|     templateUrl.value = null |     templateUrl.value = null | ||||||
|   }, 300) |   }, 300) | ||||||
| } | } | ||||||
|  |  | ||||||
| function getTickImage() { |  | ||||||
|   const imgUrl = new URL('/img/tick.png', import.meta.url) |  | ||||||
|   return imgUrl |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const isMailSenderExist = computed(() => { |  | ||||||
|   return mailSenders.value && mailSenders.value.length |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| function gotoMailSender() { |  | ||||||
|   closeSendEstimateModal() |  | ||||||
|   router.push('/admin/settings/mail-sender') |  | ||||||
| } |  | ||||||
| </script> | </script> | ||||||
|  | |||||||
| @ -15,28 +15,18 @@ | |||||||
|       </div> |       </div> | ||||||
|     </template> |     </template> | ||||||
|     <form v-if="!isPreview" action=""> |     <form v-if="!isPreview" action=""> | ||||||
|       <!-- v-if --> |       <div class="px-8 py-8 sm:p-6"> | ||||||
|       <div v-if="isMailSenderExist" class="px-8 py-8 sm:p-6"> |  | ||||||
|         <BaseInputGrid layout="one-column" class="col-span-7"> |         <BaseInputGrid layout="one-column" class="col-span-7"> | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
|             :label="$tc('settings.mail_sender.title', 1)" |             :label="$t('general.from')" | ||||||
|             required |             required | ||||||
|             :error=" |             :error="v$.from.$error && v$.from.$errors[0].$message" | ||||||
|               v$.mail_sender_id.$error && v$.mail_sender_id.$errors[0].$message |  | ||||||
|             " |  | ||||||
|           > |           > | ||||||
|             <BaseMultiselect |             <BaseInput | ||||||
|               v-model="invoiceMailForm.mail_sender_id" |               v-model="invoiceMailForm.from" | ||||||
|               :invalid="v$.mail_sender_id.$error" |               type="text" | ||||||
|               label="name" |               :invalid="v$.from.$error" | ||||||
|               :options="mailSenders" |               @input="v$.from.$touch()" | ||||||
|               value-prop="id" |  | ||||||
|               :can-deselect="false" |  | ||||||
|               :can-clear="false" |  | ||||||
|               :placeholder="$t(`settings.mail_sender.select_mail_sender`)" |  | ||||||
|               searchable |  | ||||||
|               track-by="name" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|             /> |             /> | ||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
| @ -75,48 +65,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <!-- v-else --> |       <BaseModalFooter> | ||||||
|       <div v-else-if="!isMailSenderExist && !isFetchingInitialData"> |  | ||||||
|         <FeedbackAlert |  | ||||||
|           :title="$t('settings.mail_sender.no_mail_sender_found')" |  | ||||||
|           :description=" |  | ||||||
|             $t('settings.mail_sender.no_mail_sender_found_description') |  | ||||||
|           " |  | ||||||
|           type="warning" |  | ||||||
|         > |  | ||||||
|           <template #action> |  | ||||||
|             <div class="mt-4"> |  | ||||||
|               <div class="-mx-2 -my-1.5 flex"> |  | ||||||
|                 <button |  | ||||||
|                   type="button" |  | ||||||
|                   class=" |  | ||||||
|                     bg-yellow-50 |  | ||||||
|                     px-2 |  | ||||||
|                     py-1.5 |  | ||||||
|                     rounded-md |  | ||||||
|                     text-sm |  | ||||||
|                     font-medium |  | ||||||
|                     text-yellow-800 |  | ||||||
|                     hover:bg-yellow-100 |  | ||||||
|                     focus:outline-none |  | ||||||
|                     focus:ring-2 |  | ||||||
|                     focus:ring-offset-2 |  | ||||||
|                     focus:ring-offset-yellow-50 |  | ||||||
|                     focus:ring-yellow-600 |  | ||||||
|                   " |  | ||||||
|                   @click="gotoMailSender" |  | ||||||
|                 > |  | ||||||
|                   {{ $t('settings.mail_sender.manage_mail_sender') }} |  | ||||||
|                 </button> |  | ||||||
|               </div> |  | ||||||
|             </div> |  | ||||||
|           </template> |  | ||||||
|         </FeedbackAlert> |  | ||||||
|       </div> |  | ||||||
|       <!-- end v-if-else --> |  | ||||||
|       <div |  | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -126,7 +75,6 @@ | |||||||
|           {{ $t('general.cancel') }} |           {{ $t('general.cancel') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           v-if="isMailSenderExist" |  | ||||||
|           :loading="isLoading" |           :loading="isLoading" | ||||||
|           :disabled="isLoading" |           :disabled="isLoading" | ||||||
|           variant="primary" |           variant="primary" | ||||||
| @ -143,7 +91,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.preview') }} |           {{ $t('general.preview') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|     <div v-else> |     <div v-else> | ||||||
|       <div class="my-6 mx-4 border border-gray-200 relative"> |       <div class="my-6 mx-4 border border-gray-200 relative"> | ||||||
| @ -164,9 +112,7 @@ | |||||||
|           style="min-height: 500px" |           style="min-height: 500px" | ||||||
|         ></iframe> |         ></iframe> | ||||||
|       </div> |       </div> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -190,7 +136,7 @@ | |||||||
|           /> |           /> | ||||||
|           {{ $t('general.send') }} |           {{ $t('general.send') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </div> |     </div> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
| @ -204,24 +150,18 @@ import { useI18n } from 'vue-i18n' | |||||||
| import { useInvoiceStore } from '@/scripts/admin/stores/invoice' | import { useInvoiceStore } from '@/scripts/admin/stores/invoice' | ||||||
| import { useVuelidate } from '@vuelidate/core' | import { useVuelidate } from '@vuelidate/core' | ||||||
| import { required, email, helpers } from '@vuelidate/validators' | import { required, email, helpers } from '@vuelidate/validators' | ||||||
| import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender' | import { useMailDriverStore } from '@/scripts/admin/stores/mail-driver' | ||||||
| import FeedbackAlert from '@/scripts/admin/components/FeedbackAlert.vue' |  | ||||||
| import { useRouter } from 'vue-router' |  | ||||||
|  |  | ||||||
| const modalStore = useModalStore() | const modalStore = useModalStore() | ||||||
| const companyStore = useCompanyStore() | const companyStore = useCompanyStore() | ||||||
| const notificationStore = useNotificationStore() | const notificationStore = useNotificationStore() | ||||||
| const invoiceStore = useInvoiceStore() | const invoiceStore = useInvoiceStore() | ||||||
| const mailSenderStore = useMailSenderStore() | const mailDriverStore = useMailDriverStore() | ||||||
| const router = useRouter() |  | ||||||
|  |  | ||||||
| const { t } = useI18n() | const { t } = useI18n() | ||||||
| let isLoading = ref(false) | let isLoading = ref(false) | ||||||
| const templateUrl = ref('') | const templateUrl = ref('') | ||||||
| const isPreview = ref(false) | const isPreview = ref(false) | ||||||
| const mailSenders = ref(null) |  | ||||||
| const isFetchingInitialData = ref(false) |  | ||||||
| const emailTemplates = ref(null) |  | ||||||
|  |  | ||||||
| const emit = defineEmits(['update']) | const emit = defineEmits(['update']) | ||||||
|  |  | ||||||
| @ -235,7 +175,7 @@ const invoiceMailFields = ref([ | |||||||
|  |  | ||||||
| const invoiceMailForm = reactive({ | const invoiceMailForm = reactive({ | ||||||
|   id: null, |   id: null, | ||||||
|   mail_sender_id: null, |   from: null, | ||||||
|   to: null, |   to: null, | ||||||
|   subject: 'New Invoice', |   subject: 'New Invoice', | ||||||
|   body: null, |   body: null, | ||||||
| @ -254,8 +194,9 @@ const modalData = computed(() => { | |||||||
| }) | }) | ||||||
|  |  | ||||||
| const rules = { | const rules = { | ||||||
|   mail_sender_id: { |   from: { | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |     required: helpers.withMessage(t('validation.required'), required), | ||||||
|  |     email: helpers.withMessage(t('validation.email_incorrect'), email), | ||||||
|   }, |   }, | ||||||
|   to: { |   to: { | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |     required: helpers.withMessage(t('validation.required'), required), | ||||||
| @ -279,25 +220,19 @@ function cancelPreview() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function setInitialData() { | async function setInitialData() { | ||||||
|  |   let admin = await companyStore.fetchBasicMailConfig() | ||||||
|  |  | ||||||
|   invoiceMailForm.id = modalStore.id |   invoiceMailForm.id = modalStore.id | ||||||
|  |  | ||||||
|  |   if (admin.data) { | ||||||
|  |     invoiceMailForm.from = admin.data.from_mail | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (modalData.value) { |   if (modalData.value) { | ||||||
|     invoiceMailForm.to = modalData.value.customer.email |     invoiceMailForm.to = modalData.value.customer.email | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   invoiceMailForm.body = companyStore.selectedCompanySettings.invoice_mail_body |   invoiceMailForm.body = companyStore.selectedCompanySettings.invoice_mail_body | ||||||
|  |  | ||||||
|   isFetchingInitialData.value = true |  | ||||||
|   let mailSenderData = await mailSenderStore.fetchMailSenders({ limit: 'all' }) |  | ||||||
|   if (mailSenderData.data) { |  | ||||||
|     mailSenders.value = mailSenderData.data.data |  | ||||||
|     let defaultMailSender = mailSenderData.data.data.find( |  | ||||||
|       (mailSender) => mailSender.is_default == true |  | ||||||
|     ) |  | ||||||
|     invoiceMailForm.mail_sender_id = defaultMailSender |  | ||||||
|       ? defaultMailSender.id |  | ||||||
|       : null |  | ||||||
|     isFetchingInitialData.value = false |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| async function submitForm() { | async function submitForm() { | ||||||
| @ -348,18 +283,4 @@ function closeSendInvoiceModal() { | |||||||
|     templateUrl.value = null |     templateUrl.value = null | ||||||
|   }, 300) |   }, 300) | ||||||
| } | } | ||||||
|  |  | ||||||
| function getTickImage() { |  | ||||||
|   const imgUrl = new URL('/img/tick.png', import.meta.url) |  | ||||||
|   return imgUrl |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const isMailSenderExist = computed(() => { |  | ||||||
|   return mailSenders.value && mailSenders.value.length |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| function gotoMailSender() { |  | ||||||
|   closeSendInvoiceModal() |  | ||||||
|   router.push('/admin/settings/mail-sender') |  | ||||||
| } |  | ||||||
| </script> | </script> | ||||||
|  | |||||||
| @ -15,28 +15,18 @@ | |||||||
|       </div> |       </div> | ||||||
|     </template> |     </template> | ||||||
|     <form v-if="!isPreview" action=""> |     <form v-if="!isPreview" action=""> | ||||||
|       <!-- v-if --> |       <div class="px-8 py-8 sm:p-6"> | ||||||
|       <div v-if="isMailSenderExist" class="px-8 py-8 sm:p-6"> |  | ||||||
|         <BaseInputGrid layout="one-column" class="col-span-7"> |         <BaseInputGrid layout="one-column" class="col-span-7"> | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
|             :label="$tc('settings.mail_sender.title', 1)" |             :label="$t('general.from')" | ||||||
|             required |             required | ||||||
|             :error=" |             :error="v$.from.$error && v$.from.$errors[0].$message" | ||||||
|               v$.mail_sender_id.$error && v$.mail_sender_id.$errors[0].$message |  | ||||||
|             " |  | ||||||
|           > |           > | ||||||
|             <BaseMultiselect |             <BaseInput | ||||||
|               v-model="paymentMailForm.mail_sender_id" |               v-model="paymentMailForm.from" | ||||||
|               :invalid="v$.mail_sender_id.$error" |               type="text" | ||||||
|               label="name" |               :invalid="v$.from.$error" | ||||||
|               :options="mailSenders" |               @input="v$.from.$touch()" | ||||||
|               value-prop="id" |  | ||||||
|               :can-deselect="false" |  | ||||||
|               :can-clear="false" |  | ||||||
|               :placeholder="$t(`settings.mail_sender.select_mail_sender`)" |  | ||||||
|               searchable |  | ||||||
|               track-by="name" |  | ||||||
|               :content-loading="isFetchingInitialData" |  | ||||||
|             /> |             /> | ||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|           <BaseInputGroup |           <BaseInputGroup | ||||||
| @ -75,48 +65,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <!-- v-else --> |       <BaseModalFooter> | ||||||
|       <div v-else-if="!isMailSenderExist && !isFetchingInitialData"> |  | ||||||
|         <FeedbackAlert |  | ||||||
|           :title="$t('settings.mail_sender.no_mail_sender_found')" |  | ||||||
|           :description=" |  | ||||||
|             $t('settings.mail_sender.no_mail_sender_found_description') |  | ||||||
|           " |  | ||||||
|           type="warning" |  | ||||||
|         > |  | ||||||
|           <template #action> |  | ||||||
|             <div class="mt-4"> |  | ||||||
|               <div class="-mx-2 -my-1.5 flex"> |  | ||||||
|                 <button |  | ||||||
|                   type="button" |  | ||||||
|                   class=" |  | ||||||
|                     bg-yellow-50 |  | ||||||
|                     px-2 |  | ||||||
|                     py-1.5 |  | ||||||
|                     rounded-md |  | ||||||
|                     text-sm |  | ||||||
|                     font-medium |  | ||||||
|                     text-yellow-800 |  | ||||||
|                     hover:bg-yellow-100 |  | ||||||
|                     focus:outline-none |  | ||||||
|                     focus:ring-2 |  | ||||||
|                     focus:ring-offset-2 |  | ||||||
|                     focus:ring-offset-yellow-50 |  | ||||||
|                     focus:ring-yellow-600 |  | ||||||
|                   " |  | ||||||
|                   @click="gotoMailSender" |  | ||||||
|                 > |  | ||||||
|                   {{ $t('settings.mail_sender.manage_mail_sender') }} |  | ||||||
|                 </button> |  | ||||||
|               </div> |  | ||||||
|             </div> |  | ||||||
|           </template> |  | ||||||
|         </FeedbackAlert> |  | ||||||
|       </div> |  | ||||||
|       <!-- end v-if-else --> |  | ||||||
|       <div |  | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -126,7 +75,6 @@ | |||||||
|           {{ $t('general.cancel') }} |           {{ $t('general.cancel') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           v-if="isMailSenderExist" |  | ||||||
|           :loading="isLoading" |           :loading="isLoading" | ||||||
|           :disabled="isLoading" |           :disabled="isLoading" | ||||||
|           variant="primary" |           variant="primary" | ||||||
| @ -143,7 +91,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.preview') }} |           {{ $t('general.preview') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|     <div v-else> |     <div v-else> | ||||||
|       <div class="my-6 mx-4 border border-gray-200 relative"> |       <div class="my-6 mx-4 border border-gray-200 relative"> | ||||||
| @ -164,9 +112,7 @@ | |||||||
|           style="min-height: 500px" |           style="min-height: 500px" | ||||||
|         ></iframe> |         ></iframe> | ||||||
|       </div> |       </div> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -190,7 +136,7 @@ | |||||||
|           /> |           /> | ||||||
|           {{ $t('general.send') }} |           {{ $t('general.send') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </div> |     </div> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
| @ -204,26 +150,20 @@ import { usePaymentStore } from '@/scripts/admin/stores/payment' | |||||||
| import { useCompanyStore } from '@/scripts/admin/stores/company' | import { useCompanyStore } from '@/scripts/admin/stores/company' | ||||||
| import { useNotificationStore } from '@/scripts/stores/notification' | import { useNotificationStore } from '@/scripts/stores/notification' | ||||||
| import { useModalStore } from '@/scripts/stores/modal' | import { useModalStore } from '@/scripts/stores/modal' | ||||||
|  | import { useMailDriverStore } from '@/scripts/admin/stores/mail-driver' | ||||||
| import { useDialogStore } from '@/scripts/stores/dialog' | import { useDialogStore } from '@/scripts/stores/dialog' | ||||||
| import { useMailSenderStore } from '@/scripts/admin/stores/mail-sender' |  | ||||||
| import FeedbackAlert from '@/scripts/admin/components/FeedbackAlert.vue' |  | ||||||
| import { useRouter } from 'vue-router' |  | ||||||
|  |  | ||||||
| const paymentStore = usePaymentStore() | const paymentStore = usePaymentStore() | ||||||
| const companyStore = useCompanyStore() | const companyStore = useCompanyStore() | ||||||
| const modalStore = useModalStore() | const modalStore = useModalStore() | ||||||
| const notificationStore = useNotificationStore() | const notificationStore = useNotificationStore() | ||||||
|  | const mailDriversStore = useMailDriverStore() | ||||||
| const dialogStore = useDialogStore() | const dialogStore = useDialogStore() | ||||||
| const mailSenderStore = useMailSenderStore() |  | ||||||
| const router = useRouter() |  | ||||||
|  |  | ||||||
| const { t } = useI18n() | const { t } = useI18n() | ||||||
| let isLoading = ref(false) | let isLoading = ref(false) | ||||||
| const templateUrl = ref('') | const templateUrl = ref('') | ||||||
| const isPreview = ref(false) | const isPreview = ref(false) | ||||||
| const mailSenders = ref(null) |  | ||||||
| const isFetchingInitialData = ref(false) |  | ||||||
| const emailTemplates = ref(null) |  | ||||||
|  |  | ||||||
| const paymentMailFields = ref([ | const paymentMailFields = ref([ | ||||||
|   'customer', |   'customer', | ||||||
| @ -235,7 +175,7 @@ const paymentMailFields = ref([ | |||||||
|  |  | ||||||
| const paymentMailForm = reactive({ | const paymentMailForm = reactive({ | ||||||
|   id: null, |   id: null, | ||||||
|   mail_sender_id: null, |   from: null, | ||||||
|   to: null, |   to: null, | ||||||
|   subject: 'New Payment', |   subject: 'New Payment', | ||||||
|   body: null, |   body: null, | ||||||
| @ -254,8 +194,9 @@ const modalData = computed(() => { | |||||||
| }) | }) | ||||||
|  |  | ||||||
| const rules = { | const rules = { | ||||||
|   mail_sender_id: { |   from: { | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |     required: helpers.withMessage(t('validation.required'), required), | ||||||
|  |     email: helpers.withMessage(t('validation.email_incorrect'), email), | ||||||
|   }, |   }, | ||||||
|   to: { |   to: { | ||||||
|     required: helpers.withMessage(t('validation.required'), required), |     required: helpers.withMessage(t('validation.required'), required), | ||||||
| @ -276,25 +217,18 @@ function cancelPreview() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function setInitialData() { | async function setInitialData() { | ||||||
|  |   let admin = await companyStore.fetchBasicMailConfig() | ||||||
|   paymentMailForm.id = modalStore.id |   paymentMailForm.id = modalStore.id | ||||||
|  |  | ||||||
|  |   if (admin.data) { | ||||||
|  |     paymentMailForm.from = admin.data.from_mail | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (modalData.value) { |   if (modalData.value) { | ||||||
|     paymentMailForm.to = modalData.value.customer.email |     paymentMailForm.to = modalData.value.customer.email | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   paymentMailForm.body = companyStore.selectedCompanySettings.payment_mail_body |   paymentMailForm.body = companyStore.selectedCompanySettings.payment_mail_body | ||||||
|  |  | ||||||
|   isFetchingInitialData.value = true |  | ||||||
|   let mailSenderData = await mailSenderStore.fetchMailSenders({ limit: 'all' }) |  | ||||||
|   if (mailSenderData.data) { |  | ||||||
|     mailSenders.value = mailSenderData.data.data |  | ||||||
|     let defaultMailSender = mailSenderData.data.data.find( |  | ||||||
|       (mailSender) => mailSender.is_default == true |  | ||||||
|     ) |  | ||||||
|     paymentMailForm.mail_sender_id = defaultMailSender |  | ||||||
|       ? defaultMailSender.id |  | ||||||
|       : null |  | ||||||
|     isFetchingInitialData.value = false |  | ||||||
|   } |  | ||||||
| } | } | ||||||
|  |  | ||||||
| async function sendPaymentData() { | async function sendPaymentData() { | ||||||
| @ -342,18 +276,4 @@ function closeSendPaymentModal() { | |||||||
|     modalStore.resetModalData() |     modalStore.resetModalData() | ||||||
|   }, 300) |   }, 300) | ||||||
| } | } | ||||||
|  |  | ||||||
| function getTickImage() { |  | ||||||
|   const imgUrl = new URL('/img/tick.png', import.meta.url) |  | ||||||
|   return imgUrl |  | ||||||
| } |  | ||||||
|  |  | ||||||
| const isMailSenderExist = computed(() => { |  | ||||||
|   return mailSenders.value && mailSenders.value.length |  | ||||||
| }) |  | ||||||
|  |  | ||||||
| function gotoMailSender() { |  | ||||||
|   closeSendPaymentModal() |  | ||||||
|   router.push('/admin/settings/mail-sender') |  | ||||||
| } |  | ||||||
| </script> | </script> | ||||||
|  | |||||||
| @ -90,15 +90,7 @@ | |||||||
|           </BaseInputGroup> |           </BaseInputGroup> | ||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           p-4 |  | ||||||
|           border-t border-solid border--200 border-modal-bg |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3 text-sm" |           class="mr-3 text-sm" | ||||||
|           variant="primary-outline" |           variant="primary-outline" | ||||||
| @ -122,7 +114,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ taxTypeStore.isEdit ? $t('general.update') : $t('general.save') }} |           {{ taxTypeStore.isEdit ? $t('general.update') : $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -87,9 +87,7 @@ | |||||||
|         </BaseInputGrid> |         </BaseInputGrid> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class="z-0 flex justify-end p-4 border-t border-gray-200 border-solid" |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3 text-sm" |           class="mr-3 text-sm" | ||||||
|           type="button" |           type="button" | ||||||
| @ -109,7 +107,7 @@ | |||||||
|           </template> |           </template> | ||||||
|           {{ $t('general.save') }} |           {{ $t('general.save') }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -172,15 +172,7 @@ | |||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div |       <BaseModalFooter> | ||||||
|         class=" |  | ||||||
|           z-0 |  | ||||||
|           flex |  | ||||||
|           justify-end |  | ||||||
|           p-4 |  | ||||||
|           border-t border-solid border-gray-light border-modal-bg |  | ||||||
|         " |  | ||||||
|       > |  | ||||||
|         <BaseButton |         <BaseButton | ||||||
|           class="mr-3" |           class="mr-3" | ||||||
|           type="button" |           type="button" | ||||||
| @ -207,7 +199,7 @@ | |||||||
|             !customFieldStore.isEdit ? $t('general.save') : $t('general.update') |             !customFieldStore.isEdit ? $t('general.save') : $t('general.update') | ||||||
|           }} |           }} | ||||||
|         </BaseButton> |         </BaseButton> | ||||||
|       </div> |       </BaseModalFooter> | ||||||
|     </form> |     </form> | ||||||
|   </BaseModal> |   </BaseModal> | ||||||
| </template> | </template> | ||||||
|  | |||||||
| @ -153,7 +153,7 @@ | |||||||
|           <BaseSwitch v-model="set_as_default" class="flex" /> |           <BaseSwitch v-model="set_as_default" class="flex" /> | ||||||
|         </div> |         </div> | ||||||
|         <div class="ml-4 right"> |         <div class="ml-4 right"> | ||||||
|           <p class="p-0 mb-1 text-base leading-snug text-black box-title"> |           <p class="p-0 mb-1 text-base leading-snug text-black dark:text-white box-title"> | ||||||
|             {{ $t('settings.disk.is_default') }} |             {{ $t('settings.disk.is_default') }} | ||||||
|           </p> |           </p> | ||||||
|         </div> |         </div> | ||||||
|  | |||||||
| @ -132,7 +132,7 @@ | |||||||
|           <BaseSwitch v-model="set_as_default" class="flex" /> |           <BaseSwitch v-model="set_as_default" class="flex" /> | ||||||
|         </div> |         </div> | ||||||
|         <div class="ml-4 right"> |         <div class="ml-4 right"> | ||||||
|           <p class="p-0 mb-1 text-base leading-snug text-black box-title"> |           <p class="p-0 mb-1 text-base leading-snug text-black dark:text-white box-title"> | ||||||
|             {{ $t('settings.disk.is_default') }} |             {{ $t('settings.disk.is_default') }} | ||||||
|           </p> |           </p> | ||||||
|         </div> |         </div> | ||||||
|  | |||||||
| @ -63,7 +63,7 @@ | |||||||
|         </div> |         </div> | ||||||
|  |  | ||||||
|         <div class="ml-4 right"> |         <div class="ml-4 right"> | ||||||
|           <p class="p-0 mb-1 text-base leading-snug text-black box-title"> |           <p class="p-0 mb-1 text-base leading-snug text-black dark:text-white box-title"> | ||||||
|             {{ $t('settings.disk.is_default') }} |             {{ $t('settings.disk.is_default') }} | ||||||
|           </p> |           </p> | ||||||
|         </div> |         </div> | ||||||
|  | |||||||
| @ -134,7 +134,7 @@ | |||||||
|           <BaseSwitch v-model="set_as_default" class="flex" /> |           <BaseSwitch v-model="set_as_default" class="flex" /> | ||||||
|         </div> |         </div> | ||||||
|         <div class="ml-4 right"> |         <div class="ml-4 right"> | ||||||
|           <p class="p-0 mb-1 text-base leading-snug text-black box-title"> |           <p class="p-0 mb-1 text-base leading-snug text-black dark:text-white box-title"> | ||||||
|             {{ $t('settings.disk.is_default') }} |             {{ $t('settings.disk.is_default') }} | ||||||
|           </p> |           </p> | ||||||
|         </div> |         </div> | ||||||
|  | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	