Esempio n. 1
0
    ?>
</td>
    <td><?php 
    echo CHtml::encode($model->changedBy);
    ?>
</td>
    <td><?php 
    echo CHtml::encode(User::getDateFormatted($model->dateChanged, $cLoc, $dateformatter));
    ?>
</td>
    <td>
      <?php 
    echo CHtml::link(Yii::t('lazy8', 'Update'), array('update', 'id' => $model->id));
    ?>
      <?php 
    if (TransRow::model()->find('customerId=' . $model->id) == null) {
        $deletebutton = CHtml::linkButton(Yii::t('lazy8', 'Delete'), array('submit' => '', 'params' => array('command' => 'delete', 'id' => $model->id), 'confirm' => Yii::t('lazy8', "Are you sure to delete?") . ' - ' . $model->name));
    } else {
        $deletebutton = CHtml::linkButton(Yii::t('lazy8', 'Delete'), array('submit' => '', 'params' => array('command' => 'admin', 'id' => $model->id), 'confirm' => Yii::t('lazy8', "You cannot delete this record because other records are dependent on it.")));
    }
    echo $deletebutton;
    ?>
	</td>
  </tr>
<?php 
}
?>
  </tbody>
</table>
<br/>
<?php 
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the primary key value. Defaults to null, meaning using the 'id' GET variable
  */
 public function loadTransRow($id = null)
 {
     if ($this->_model === null) {
         if ($id !== null || isset($_GET['id'])) {
             $this->_model = TransRow::model()->findbyPk($id !== null ? $id : $_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Esempio n. 3
0
    ?>
</td>
    <td><?php 
    echo CHtml::encode($model->changedBy);
    ?>
</td>
    <td><?php 
    echo CHtml::encode(User::getDateFormatted($model->dateChanged, $cLoc, $dateformatter));
    ?>
</td>
    <td>
      <?php 
    echo CHtml::link(Yii::t('lazy8', 'Update'), array('update', 'id' => $model->id));
    ?>
      <?php 
    if (TransRow::model()->find('accountId=' . $model->id) == null) {
        $deletebutton = CHtml::linkButton(Yii::t('lazy8', 'Delete'), array('submit' => '', 'params' => array('command' => 'delete', 'id' => $model->id), 'confirm' => Yii::t('lazy8', "Are you sure to delete?") . ' - ' . $model->name));
    } else {
        $deletebutton = CHtml::linkButton(Yii::t('lazy8', 'Delete'), array('submit' => '', 'params' => array('command' => 'admin', 'id' => $model->id), 'confirm' => Yii::t('lazy8', "You cannot delete this record because other records are dependent on it.")));
    }
    echo $deletebutton;
    ?>
	</td>
  </tr>
<?php 
}
?>
  </tbody>
</table>
<br/>
<?php 
 private function exportCompany($companyId = null)
 {
     $compName = "AllCompanies";
     if ($companyId != null) {
         $compName = CompanyController::replace_bad_filename_chars(Company::model()->findbyPk($companyId)->name);
     }
     // set headers
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Content-Description: File Transfer");
     header("Content-Type: text/xml");
     header("Content-Disposition: attachment; filename=\"lazy8webExport.Company." . $compName . "." . date('Y-m-d_H.i.s') . ".xml\"");
     header("Content-Transfer-Encoding: binary");
     //safari can't deal with this header length zero
     //		header("Content-Length: " );
     $writer = new XMLWriter();
     // Output directly to the user
     //dirname(__FILE__).DIRECTORY_SEPARATOR.'../..'.'/assets/upload.sql'
     $writer->openURI('php://output');
     $writer->startDocument('1.0', 'utf-8');
     $writer->setIndent(4);
     $writer->startElement('lazy8webport');
     $writer->writeAttribute('version', '1.00');
     $companies = array();
     if (isset($companyId)) {
         $companies[] = Company::model()->findbyPk($companyId);
     } else {
         $companies = Company::model()->findAll(array('order' => 'code'));
     }
     foreach ($companies as $company) {
         ChangeLog::addLog('OTHER', 'Company', 'Exported company ' . $company->toString());
         $writer->startElement('company');
         $writer->writeAttribute("code", $company->code);
         $writer->writeAttribute("name", $company->name);
         $writer->writeAttribute("lastAbsTransNum", $company->lastAbsTransNum);
         $allAccounts = array();
         $accountTypes = AccountType::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'code'));
         foreach ($accountTypes as $accountType) {
             $writer->startElement('accounttype');
             $writer->writeAttribute("code", $accountType->code);
             $writer->writeAttribute("name", $accountType->name);
             $writer->writeAttribute("sortorder", $accountType->sortOrder);
             $writer->writeAttribute("isinbalance", $accountType->isInBalance);
             $accounts = Account::model()->findAll(array('condition' => 'companyId=' . $company->id . ' AND accountTypeId=' . $accountType->id, 'order' => 'code'));
             foreach ($accounts as $account) {
                 $allAccounts[$account->id] = $account->code;
                 $writer->startElement('account');
                 $writer->writeAttribute("code", $account->code);
                 $writer->writeAttribute("name", $account->name);
                 $writer->endElement();
             }
             $writer->endElement();
         }
         $customers = Customer::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'code'));
         $allCustomers = array();
         foreach ($customers as $customer) {
             $writer->startElement('customer');
             $allCustomers[$customer->id] = $customer->code;
             $writer->writeAttribute("code", $customer->code);
             $writer->writeAttribute("name", $customer->name);
             $writer->writeAttribute("desc", $customer->desc);
             if (isset($allAccounts[$customer->accountId])) {
                 $writer->writeAttribute("accountcode", $allAccounts[$customer->accountId]);
             } else {
                 $writer->writeAttribute("accountcode", 0);
             }
             $writer->endElement();
         }
         $periods = Period::model()->findAll(array('condition' => 'companyId=' . $company->id, 'order' => 'dateStart'));
         foreach ($periods as $period) {
             $writer->startElement('period');
             $writer->writeAttribute("datestart", $period->dateStart);
             $writer->writeAttribute("dateend", $period->dateEnd);
             $writer->writeAttribute("lastperiodtransnum", $period->lastPeriodTransNum);
             $transactions = Trans::model()->findAll(array('condition' => 'companyId=' . $company->id . ' AND periodId=' . $period->id, 'order' => 'companyNum'));
             foreach ($transactions as $transaction) {
                 $writer->startElement('transaction');
                 $writer->writeAttribute("code", $transaction->companyNum);
                 $writer->writeAttribute("periodnum", $transaction->periodNum);
                 $writer->writeAttribute("regdate", $transaction->regDate);
                 $writer->writeAttribute("invdate", $transaction->invDate);
                 $writer->writeAttribute("notes", $transaction->notes);
                 $writer->writeAttribute("fileinfo", $transaction->fileInfo);
                 $transrows = TransRow::model()->findAll(array('condition' => 'transId=' . $transaction->id, 'order' => 'amount DESC'));
                 foreach ($transrows as $transrow) {
                     $writer->startElement('amount');
                     $writer->writeAttribute("accountcode", isset($allAccounts[$transrow->accountId]) ? $allAccounts[$transrow->accountId] : 0);
                     $writer->writeAttribute("customercode", isset($allCustomers[$transrow->customerId]) ? $allCustomers[$transrow->customerId] : 0);
                     $writer->writeAttribute("notes", $transrow->notes);
                     $writer->writeAttribute("amount", $transrow->amount);
                     $writer->endElement();
                 }
                 $writer->endElement();
             }
             $writer->endElement();
         }
         yii::app()->onExport(new Lazy8Event(array('exportobject' => 'Company', 'writer' => $writer), $company->id));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     $writer->flush();
     return;
     //we may not send any more to the screen or it will mess up the file we just sent!
 }