12 lines
1.1 KiB
PHP
12 lines
1.1 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class Migration_Remove_supplier_invoice_approval extends CI_Migration
|
|
{
|
|
public function up(){
|
|
if($this->db->table_exists('approval_requests'))$this->db->query("UPDATE approval_requests SET status='rejected',completed_at=COALESCE(completed_at,NOW()) WHERE entity_type='supplier_invoice' AND status='pending'");
|
|
if($this->db->table_exists('approval_workflows'))$this->db->where('entity_type','supplier_invoice')->update('approval_workflows',array('is_active'=>0));
|
|
if($this->db->table_exists('supplier_invoices')&&$this->db->table_exists('transaction_attachments'))$this->db->query("UPDATE supplier_invoices si SET si.status='approved' WHERE si.status='submitted' AND EXISTS(SELECT 1 FROM transaction_attachments ta WHERE ta.entity_type='supplier_invoice' AND ta.entity_id=si.id) AND NOT EXISTS(SELECT 1 FROM supplier_invoice_lines sil WHERE sil.supplier_invoice_id=si.id AND sil.match_status<>'matched')");
|
|
}
|
|
public function down(){if($this->db->table_exists('approval_workflows'))$this->db->where('entity_type','supplier_invoice')->update('approval_workflows',array('is_active'=>1));}
|
|
}
|