Example #1
0
	public function recur()
	{
		$invoice = invoice::select($this->id);
		$ni = new invoice();
		$ni->biller_id = $invoice['biller_id'];
		$ni->customer_id = $invoice['customer_id'];
		$ni->type_id = $invoice['type_id'];
		$ni->preference_id = $invoice['preference_id'];
		//$ni->date = $invoice['date_original'];
		$ni->date = date('Y-m-d');
		$ni->custom_field1 = $invoice['custom_field1'];
		$ni->custom_field2 = $invoice['custom_field2'];
		$ni->custom_field3 = $invoice['custom_field3'];
		$ni->custom_field4 = $invoice['custom_field4'];
		$ni->note = $invoice['note'];
		$ni_id = $ni->insert();
		//insert each line item
		foreach ($invoice['invoice_items'] as $key => $value)
		{
			$nii = new invoice();
			$nii->invoice_id=$ni_id;
			$nii->quantity=$invoice['invoice_items'][$key]['quantity'];
			$nii->product_id=$invoice['invoice_items'][$key]['product_id'];
			$nii->unit_price=$invoice['invoice_items'][$key]['unit_price'];
			$nii->tax_amount=$invoice['invoice_items'][$key]['tax_amount'];
			$nii->gross_total=$invoice['invoice_items'][$key]['gross_total'];
			$nii->description=$invoice['invoice_items'][$key]['description'];
			$nii->total=$invoice['invoice_items'][$key]['total'];
			$nii->tax=$invoice['invoice_items'][$key]['tax'];
			$nii_id = $nii->insert_item();
		}

		return $ni_id;
	}
 public function recur()
 {
     $invoice = $this->select($this->id, $this->domain_id);
     $ni = new invoice();
     $ni->domain_id = $invoice['domain_id'];
     // Next Index is obtained during insert
     // $ni->index_id     = $invoice['index_id'];
     $ni->biller_id = $invoice['biller_id'];
     $ni->customer_id = $invoice['customer_id'];
     $ni->type_id = $invoice['type_id'];
     $ni->preference_id = $invoice['preference_id'];
     //$ni->date = $invoice['date_original'];
     // Use todays date
     $ni->date = date('Y-m-d');
     $ni->custom_field1 = $invoice['custom_field1'];
     $ni->custom_field2 = $invoice['custom_field2'];
     $ni->custom_field3 = $invoice['custom_field3'];
     $ni->custom_field4 = $invoice['custom_field4'];
     $ni->note = $invoice['note'];
     $ni_id = $ni->insert();
     //insert each line item
     $nii = new invoice();
     $nii->invoice_id = $ni_id;
     $nii->domain_id = $ni->domain_id;
     foreach ($invoice['invoice_items'] as $k => $v) {
         $nii->quantity = $v['quantity'];
         $nii->product_id = $v['product_id'];
         $nii->unit_price = $v['unit_price'];
         $nii->tax_amount = $v['tax_amount'];
         $nii->gross_total = $v['gross_total'];
         $nii->description = $v['description'];
         $nii->total = $v['total'];
         $nii->attribute = $v['attribute'];
         $nii->tax = $v['tax'];
         $nii_id = $nii->insert_item();
     }
     return $ni_id;
 }