예제 #1
0
파일: Aps.php 프로젝트: ranvijayj/htmlasa
    /**
     * Delete AP with rows in relative tables
     * @param $apId
     */
    public static function deleteAP($apId)
    {
        $ap = Aps::model()->with('document.image')->findByPk($apId);
        if ($ap) {
            $document = $ap->document;
            $image = $document->image;
            $image->delete();
            $document->delete();

            ApPayments::model()->deleteAllByAttributes(array(
                'AP_ID' => $apId,
            ));

            GlDistDetails::model()->deleteAllByAttributes(array(
                'AP_ID' => $apId,
            ));

            // delete thumbnail
            $filePath = 'protected/data/thumbs/' . $ap->Document_ID . '.jpg';
            if (file_exists($filePath)) {
                @unlink($filePath);
            }

            // delete library links
            LibraryDocs::deleteDocumentLinks($ap->Document_ID);

            $ap->delete();
        }
    }
예제 #2
0
파일: Ars.php 프로젝트: ranvijayj/htmlasa
    /**
     * Delete AR with rows in relative tables
     * @param $arID
     */
    public static function deleteAR($arID)
    {
        $ar = Ars::model()->with('document.image')->findByPk($arID);
        if ($ar) {
            $document = $ar->document;
            $image = $document->image;
            $image->delete();
            $document->delete();

            // delete thumbnail
            $filePath = 'protected/data/thumbs/' . $ar->Document_ID . '.jpg';
            if (file_exists($filePath)) {
                @unlink($filePath);
            }

            // delete library links
            LibraryDocs::deleteDocumentLinks($ar->Document_ID);

            $ar->delete();
        }
    }
예제 #3
0
    /**
     * Assign LB or GF document to subsection
     * @param $subsId
     * @param $docId
     * @param $access
     */
    public static function assignLBDocumentToSubsection($subsId, $docId, $access)
    {
        $subsId = intval($subsId);
        $docId = intval($docId);
        $access = intval($access);
        if ($subsId > 0 && $docId > 0 && $access <= 1) {
            $libDoc = LibraryDocs::model()->findByAttributes(array(
                'Document_ID' => $docId,
                'Subsection_ID' => $subsId,
            ));
            if (!$libDoc) {
                $condition = new CDbCriteria();
                $condition->select = 'max(Sort_Numb) as Sort_Numb';
                $condition->condition = "t.Subsection_ID = '" . $subsId . "'";
                $sortNumRes = LibraryDocs::model()->find($condition);
                if ($sortNumRes) {
                    $sortNum = intval($sortNumRes->Sort_Numb) + 1;
                } else {
                    $sortNum = 0;
                }

                $libDoc = new LibraryDocs();
                $libDoc->Access_Type = $access;
                $libDoc->Document_ID = $docId;
                $libDoc->Subsection_ID = $subsId;
                $libDoc->Sort_Numb = $sortNum;
                if ($libDoc->validate()) {
                    $libDoc->save();
                }
            }
        }
    }
예제 #4
0
파일: W9.php 프로젝트: ranvijayj/htmlasa
    /**
     * Delete W9 with rows in relative tables
     * @param $w9Id
     */
    public static function deleteW9($w9Id)
    {
        $w9 = W9::model()->with('document.image')->findByPk($w9Id);
        if ($w9) {
            $document = $w9->document;

            $documentW9s = W9::model()->findAllByAttributes(array(
                'Document_ID' => $document->Document_ID,
            ));

            if (count($documentW9s) <= 1) {
                $image = $document->image;
                if ($image) $image->delete();
                $document->delete();
            }

            // delete thumbnail
            $filePath = 'protected/data/thumbs/' . $w9->Document_ID . '.jpg';
            if (file_exists($filePath)) {
                @unlink($filePath);
            }

            // delete library links
            LibraryDocs::deleteDocumentLinks($w9->Document_ID);

            $w9->delete();
        }
    }
예제 #5
0
    /**
     * Delete document with rows in relative tables
     * @param $documentId
     */
    public static function deleteDocument($documentId) {
        $document = Documents::model()->findByPk($documentId);
        if ($document) {
            if ($document->Document_Type == self::W9) {
                $w9s = W9::model()->findAllByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                foreach ($w9s as $w9) {
                    W9::deleteW9($w9->W9_ID);
                }
            } else if ($document->Document_Type == self::AP) {
                $ap = Aps::model()->findByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                if ($ap) {
                    Aps::deleteAP($ap->AP_ID);
                }
            } else if ($document->Document_Type ==  self::PM) {
                $payment = Payments::model()->findByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                if ($payment) {
                    Payments::deletePayment($payment->Payment_ID);
                }
            } else if ($document->Document_Type == self::PO) {
                $po = Pos::model()->findByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                if ($po) {
                    Pos::deletePO($po->PO_ID);
                }
            } else if ($document->Document_Type == self::PC) {
                $pc = Pcs::model()->findByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                if ($pc) {
                    Pcs::deletePC($pc->PC_ID);
                }
            } else if ($document->Document_Type == self::AR) {
                $ar = Ars::model()->findByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                if ($ar) {
                    Ars::deleteAR($ar->AR_ID);
                }
            } else if ($document->Document_Type == self::PR) {
                $payroll = Payrolls::model()->findByAttributes(array(
                    'Document_ID' => $documentId,
                ));
                if ($payroll) {
                    Payrolls::deletePayroll($payroll->Payroll_ID);
                }
            }  else {
                $image = $document->image;
                $image->delete();
                $document->delete();

                // delete thumbnail
                $filePath = 'protected/data/thumbs/' . $documentId . '.jpg';
                if (file_exists($filePath)) {
                    @unlink($filePath);
                }

                // delete library links
                LibraryDocs::deleteDocumentLinks($documentId);
            }
        }
    }
예제 #6
0
    /**
     * Delete Payment with rows in relative tables
     * @param $paymentId
     */
    public static function deletePayment($paymentId)
    {
        $payment = Payments::model()->with('document.image')->findByPk($paymentId);
        if ($payment) {
            $document = $payment->document;
            $image = $document->image;
            $image->delete();
            $document->delete();

            PaymentsInvoice::model()->deleteAllByAttributes(array(
                'Payment_ID' => $paymentId,
            ));

            ApPayments::model()->deleteAllByAttributes(array(
                'Payment_ID' => $paymentId,
            ));

            // delete thumbnail
            $filePath = 'protected/data/thumbs/' . $payment->Document_ID . '.jpg';
            if (file_exists($filePath)) {
                @unlink($filePath);
            }

            // delete library links
            LibraryDocs::deleteDocumentLinks($payment->Document_ID);

            $payment->delete();
        }
    }
예제 #7
0
 /**
  * Delete Storage with sections and subsections
  * @param $id
  */
 public static function deleteStorage($id)
 {
     $storage = Storages::model()->with('sections.subsections')->findByPk($id);
     if ($storage) {
         if (count($storage->sections) > 0) {
             foreach($storage->sections as $section) {
                 if (count($section->subsections)) {
                     foreach ($section->subsections as $subsection) {
                         LibraryDocs::model()->deleteAllByAttributes(array(
                             'Subsection_ID' => $subsection->Subsection_ID,
                         ));
                         $subsection->delete();
                     }
                 }
                 $section->delete();
             }
         }
         $storage->delete();
     }
 }
예제 #8
0
파일: Pos.php 프로젝트: ranvijayj/htmlasa
    /**
     * Delete PO with rows in relative tables
     * @param $poId
     */
    public static function deletePO($poId)
    {
        $po = Pos::model()->with('document.image')->findByPk($poId);
        if ($po) {
            $document = $po->document;
            $image = $document->image;
            $image->delete();
            $document->delete();

            PoDists::model()->deleteAllByAttributes(array(
                'PO_ID' => $poId,
            ));

            PoDescDetail::model()->deleteAllByAttributes(array(
                'PO_ID' => $poId,
            ));

            PoPmtsTraking::model()->deleteAllByAttributes(array(
                'PO_ID' => $poId,
            ));

            // delete thumbnail
            $filePath = 'protected/data/thumbs/' . $po->Document_ID . '.jpg';
            if (file_exists($filePath)) {
                @unlink($filePath);
            }

            // delete library links
            LibraryDocs::deleteDocumentLinks($po->Document_ID);

            $po->delete();
        }
    }
예제 #9
0
 /**
  * Delete subsection
  * @param $id
  */
 public static function deleteSubsection($id)
 {
     $subsection = Subsections::model()->findByPk($id);
     LibraryDocs::model()->deleteAllByAttributes(array(
         'Subsection_ID' => $subsection->Subsection_ID,
     ));
     $subsection->delete();
 }
예제 #10
0
    /**
     * Delete sub section
     * @param $id
     */
    public static function deleteSubsection($section_id,$subsection_id)
    {
        $subsection = Subsections::model()->findByAttributes(array(
            'Subsection_ID' =>$subsection_id
        ));

        if ($subsection) {
                    LibraryDocs::model()->deleteAllByAttributes(array(
                        'Subsection_ID' => $subsection->Subsection_ID,
                    ));

                    $subsection->delete();

        }

        //delete section if it is now have no panels
        $section = Sections::model()->findByPk($section_id);
        if (!count($section->subsections)) {
            $section->delete();
        }
    }