���Root Mod By V1rus_Alfa
User / IP
:
216.73.217.78
Host / Server
:
195.214.235.115 / npln.ir
System
:
Linux damavand.pws-dns.net 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
Command
|
Upload
|
Mass Deface
|
Create
:
/
home2
/
cutunixc
/
repositories
/
npln
/
app
/
Exports
/
Viewing: DocumentsExport.php
<?php namespace App\Exports; use App\Models\Document; use Maatwebsite\Excel\Concerns\FromCollection; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithMapping; use Maatwebsite\Excel\Events\AfterSheet; use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Illuminate\Support\Facades\Auth; class DocumentsExport implements FromCollection, WithHeadings , WithEvents ,ShouldAutoSize { /** * @return \Illuminate\Support\Collection */ public $headings_array=[ 'محل واریز', 'نام مشتری', 'طراح', 'کد سفارش', 'بستانکار', 'بدهکار', 'تاریخ و ساعت', ]; public $cols=[ 'documents.to_id', 'documents.user_id', 'documents.factor_id', 'documents.order_id', 'documents.sum_bes', 'documents.sum_bed', 'documents.date', ]; public function headings(): array { return $this->headings_array; } protected $documentsCount; public $start; public $end; public $to_id; public $order_number; public $employe_id; public $order_id; public $from_name; public $to_name; public function proccess_employe($row) { if ($row->order && $row->order->employe_id){ $result= $row->order->employ->first_name.' '.$row->order->employ->last_name; }else { $result= "----"; } return $result; } public function proccess_name($row) { $result='---'; if (isset($row->customer) && $row->customer && ($row->customer->first_name || $row->customer->last_name || $row->customer->mobile)){ if ( $row->customer->first_name && $row->customer->last_name){ $result= $row->customer->first_name.' '.$row->customer->last_name; }elseif($row->customer->first_name){ $result=$row->customer->first_name; }else{ $result=' '; } if(Auth::user()->roll == 'ADMIN' || Auth::user()->roll == 'secretary'){ $result=$result.'( '.$row->customer->mobile.' )'; } }else{ if (isset($row->user) && $row->user){ if ( $row->user->first_name && $row->user->last_name){ $result= $row->user->first_name.' '.$row->user->last_name; }elseif($row->user->first_name){ $result=$row->user->first_name; }else{ $result=' '; } if(Auth::user()->roll == 'ADMIN' || Auth::user()->roll == 'secretary'){ $result=$result.'( '.$row->user->mobile.' )'; } } } return $result; } public function __construct($start,$end,$to_id,$order_number,$employe_id,$order_id,$from_name,$to_name) { $this->start = $start; $this->end = $end; $this->to_id = $to_id; $this->order_number = $order_number; $this->employe_id = $employe_id; $this->order_id = $order_id; $this->from_name = $from_name; $this->to_name = $to_name; } public function collection() { $documents=Document:: when($this->start,function($q){ $q->where('documents.created_at', '>=', $this->start); }) ->when($this->end,function($q){ $q->where('documents.created_at', '<=', $this->end); }) ->when($this->order_id,function($q){ $q->where('documents.order_id',$this->order_id); }) ->when($this->to_id,function($q){ $q->where('documents.to_id',$this->to_id); }) ->when($this->from_name,function($q){ $q->whereHas('from',function($q){ $q->where('name', 'like', '%'.$this->from_name.'%'); }); }) ->when($this->order_number,function($q){ $q->whereHas('order',function($q){ $q->where('number', 'like', '%'.$this->order_number.'%'); }); }) ->when($this->employe_id,function($q){ $q->whereHas('order',function($q){ $q->where('employe_id', $this->employe_id ); }); }) ->when($this->to_name,function($q){ $q->whereHas('to',function($q){ $q->where('name', 'like', '%'.$this->to_name.'%'); }); }) ->when($this->cols,function($q){ $q->select($this->cols); } ) ->orderBy('documents.id','desc')->get(); foreach ($documents as $item) { if($item->to){ $item['to_id']=$item->to->name; }else{ $item['to_id']='شرح در فاکتور'; } if($item['user_id']){ $item['user_id']=$this->proccess_name($item->order); } if($item['factor_id']){ $item['factor_id']=$this->proccess_employe($item); } if($item['order_id'] && $item->order){ $item['order_id']=$item->order->number; }else{ $item['order_id']= null; } } $this->documentsCount=count($documents)+1; return $documents; } public function registerEvents(): array { $styleArray = ['font' => ['bold' => true]]; return [ AfterSheet::class => function (AfterSheet $event) use ($styleArray) { // bold heading $event->sheet->getStyle("A1:BJ{$this->documentsCount}") ->applyFromArray($styleArray); // change direction to rtl $event->sheet->setRightToLeft(true); // center all text $event->sheet ->getStyle("A1:BJ{$this->documentsCount}") ->getAlignment()->setHorizontal('center'); }, ]; } }
Coded With 💗 by
0x6ick Mod By V1rus_Alfa