mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:07:32 -05:00 
			
		
		
		
	Task imports
This commit is contained in:
		
							parent
							
								
									aaa84c9c92
								
							
						
					
					
						commit
						4db163c4e1
					
				@ -22,7 +22,10 @@ class ImportRequest extends Request
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function authorize() : bool
 | 
					    public function authorize() : bool
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return auth()->user()->isAdmin();
 | 
					        /** @var \App\Models\User $user */
 | 
				
			||||||
 | 
					        $user = auth()->user();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $user->isAdmin();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function rules()
 | 
					    public function rules()
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ class TaskMap
 | 
				
			|||||||
            4 => 'client.name',
 | 
					            4 => 'client.name',
 | 
				
			||||||
            5 => 'client.email',
 | 
					            5 => 'client.email',
 | 
				
			||||||
            6 => 'task.description',
 | 
					            6 => 'task.description',
 | 
				
			||||||
            7 => 'task.is_billable',
 | 
					            7 => 'task.billable',
 | 
				
			||||||
            8 => 'task.start_date',
 | 
					            8 => 'task.start_date',
 | 
				
			||||||
            9 => 'task.end_date',
 | 
					            9 => 'task.end_date',
 | 
				
			||||||
            10 => 'task.start_time',
 | 
					            10 => 'task.start_time',
 | 
				
			||||||
 | 
				
			|||||||
@ -162,8 +162,9 @@ class BaseImport
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private function groupTasks($csvData, $key)
 | 
					    private function groupTasks($csvData, $key)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        nlog($csvData[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (! $key || count(array_column($csvData, $key)) == 0) {
 | 
					        if (! $key || !is_array($csvData) || count($csvData) == 0 || !isset($csvData[0]['task.number']) || empty($csvData[0]['task.number'])) {
 | 
				
			||||||
            return $csvData;
 | 
					            return $csvData;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@ -495,7 +496,7 @@ class BaseImport
 | 
				
			|||||||
                ];
 | 
					                ];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
nlog($count);
 | 
					        
 | 
				
			||||||
        return $count;
 | 
					        return $count;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -179,6 +179,7 @@ class BaseTransformer
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function getClient($client_name, $client_email)
 | 
					    public function getClient($client_name, $client_email)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (! empty($client_name)) {
 | 
					        if (! empty($client_name)) {
 | 
				
			||||||
            $client_id_search = Client::query()->where('company_id', $this->company->id)
 | 
					            $client_id_search = Client::query()->where('company_id', $this->company->id)
 | 
				
			||||||
                ->where('is_deleted', false)
 | 
					                ->where('is_deleted', false)
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,10 @@ class TaskTransformer extends BaseTransformer
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->stubbed_timestamp = time();
 | 
					        $this->stubbed_timestamp = time();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $task_data = reset($task_items_data);
 | 
					        if(count($task_items_data) == count($task_items_data, COUNT_RECURSIVE)) 
 | 
				
			||||||
 | 
					            $task_data = $task_items_data;
 | 
				
			||||||
 | 
					        else 
 | 
				
			||||||
 | 
					            $task_data = reset($task_items_data);
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        $clientId = $this->getClient(
 | 
					        $clientId = $this->getClient(
 | 
				
			||||||
            $this->getString($task_data, 'client.name'),
 | 
					            $this->getString($task_data, 'client.name'),
 | 
				
			||||||
 | 
				
			|||||||
@ -74,7 +74,7 @@ class CSVIngest implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $engine = $this->bootEngine();
 | 
					        $engine = $this->bootEngine();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        foreach (['client', 'product', 'invoice', 'payment', 'vendor', 'expense', 'quote', 'bank_transaction', 'recurring_invoice'] as $entity) {
 | 
					        foreach (['client', 'product', 'invoice', 'payment', 'vendor', 'expense', 'quote', 'bank_transaction', 'recurring_invoice', 'task'] as $entity) {
 | 
				
			||||||
            $engine->import($entity);
 | 
					            $engine->import($entity);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -83,6 +83,8 @@ class InstantPayment
 | 
				
			|||||||
                ->with(['message' => 'No payable invoices selected.']);
 | 
					                ->with(['message' => 'No payable invoices selected.']);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $invoices = Invoice::query()->whereIn('id', $this->transformKeys($payable_invoices->pluck('invoice_id')->toArray()))->withTrashed()->get();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $client = $invoices->first()->client;
 | 
					        $client = $invoices->first()->client;
 | 
				
			||||||
        $settings = $client->getMergedSettings();
 | 
					        $settings = $client->getMergedSettings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user