示例#1
0
 private function calc($account_type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $account_type);
     $accounts = Accounts::model()->findAll($criteria);
     $sum = 0;
     $data = array();
     $data[] = array("id" => '', 'name' => Acctype::model()->getName($account_type), 'neg' => '', 'pos' => '', 'sum' => '', 'id6111' => '');
     $total = array("id" => '', 'name' => Yii::t("app", "Total"), 'neg' => 0, 'pos' => 0, 'sum' => 0, 'id6111' => '');
     foreach ($accounts as $account) {
         //echo $this->from_date.":00<br>";
         $sum = $account->getTotal($this->from_date . ":00", $this->to_date . ":00");
         $neg = $account->getNeg($this->from_date . ":00", $this->to_date . ":00");
         $pos = $account->getPos($this->from_date . ":00", $this->to_date . ":00");
         $total['sum'] += $sum;
         $total['neg'] += $neg;
         $total['pos'] += $pos;
         if ($sum != 0 || $neg != 0 || $pos != 0) {
             $data[] = array('id' => $account->id, 'name' => $account->name, 'neg' => $neg, 'pos' => $pos, 'sum' => $sum, 'id6111' => $account->id6111);
         }
     }
     $data[] = $total;
     return $data;
 }
示例#2
0
 private function calc($account_type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $account_type);
     $accounts = Accounts::model()->findAll($criteria);
     $sum = 0;
     $data = array();
     $stime = "00:00:01";
     $etime = "23:59:59";
     $from_date = "01/01/{$this->year} {$stime}";
     $to_date = "31/12/{$this->year} {$etime}";
     foreach ($accounts as $account) {
         $sum = $account->getTotal($from_date, $to_date);
         if ($sum != 0) {
             $accounty = array('id' => $account->id, 'name' => $account->name, 'sum' => $sum, 'id6111' => $account->id6111);
             for ($x = 1; $x <= 12; $x++) {
                 if ($x <= 9) {
                     $a = "0{$x}";
                 } else {
                     $a = $x;
                 }
                 $last = 31;
                 while (!checkdate($x, $last, $this->year)) {
                     $last--;
                 }
                 $accounty[$x] = $account->getTotal("01/{$a}/{$this->year} {$stime}", "{$last}/{$a}/{$this->year} {$etime}");
             }
             $data[] = $accounty;
         }
     }
     return $data;
 }
示例#3
0
 protected function assertAccountCreated()
 {
     $lead = Accounts::model()->findByAttributes(array('name' => 'testAccount'));
     $this->assertTrue($lead !== null);
     X2_TEST_DEBUG_LEVEL > 1 && println('account created');
     return $lead;
 }
 public function loadModel($id)
 {
     $model = Accounts::model()->visible()->with('role_groups')->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function UpdateAccount()
 {
     $account = Accounts::model()->findByPk(Yii::app()->user->getAccountid());
     $model = new TimezoneForm();
     $model->timezone = $account->timezone_id;
     $model->account_id = $account->account_id;
     return $model;
 }
示例#6
0
 public function getSrcTax($id)
 {
     $model = Accounts::model()->findByPk($id);
     if ($model === null) {
         return false;
     } else {
         return $model->src_tax;
     }
 }
 public static function masterAdmin()
 {
     $result = false;
     $reader = Accounts::model()->findAll();
     if (count($reader) > 0) {
         $result = true;
     }
     return $result;
 }
 public function actionIndex()
 {
     Yii::import("application.models.*");
     set_time_limit(0);
     $accounts = Accounts::model()->findAll();
     foreach ($accounts as $currentValue) {
         $currentValue->checkWebsiteStatus();
     }
 }
示例#9
0
 public function getTotal($from_date, $to_date)
 {
     $sum = 0;
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $this->id);
     $accounts = Accounts::model()->findAll($criteria);
     foreach ($accounts as $account) {
         $sum += $account->getTotal($from_date, $to_date);
     }
     return $sum;
 }
示例#10
0
文件: Item.php 项目: hkhateb/linet3
 public function findByPk($id, $condition = '', $params = array())
 {
     $model = parent::findByPk($id, $condition = '', $params = array());
     if ($model !== null) {
         $incomeMap = UserIncomeMap::model()->findByPk(array('user_id' => Yii::app()->user->id, 'itemVatCat_id' => $model->itemVatCat_id));
         if ($incomeMap !== null) {
             $model->vat = Accounts::model()->getSrcTax($incomeMap->account_id);
         } else {
             $model->vat = 0;
         }
     }
     return $model;
 }
示例#11
0
 private function chkType($account_id)
 {
     $model = Accounts::model()->findByPk($account_id);
     if ($model === NULL) {
         return NULL;
     }
     if ($model->type == $this->type) {
         return $account_id;
     } elseif ($this->type == '') {
         return $account_id;
     } else {
         return null;
     }
 }
示例#12
0
 private function calc($account_type)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "type = :type";
     $criteria->params = array(':type' => $account_type);
     $accounts = Accounts::model()->findAll($criteria);
     $sum = 0;
     $data = array();
     foreach ($accounts as $account) {
         $sum = $account->getTotal($this->from_date . ":00", $this->to_date . ":00");
         if ($sum != 0) {
             $data[] = array('id' => $account->id, 'name' => $account->name, 'sum' => $sum, 'id6111' => $account->id6111);
         }
     }
     return $data;
 }
示例#13
0
 public function actionWhatsNew()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
         $lastLogin = $user->lastLogin;
         $contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
         $sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $arr = array_merge($contacts, $actions, $sales, $accounts);
         $records = Record::convert($arr);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
         $this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
     } else {
         $this->redirect('login');
     }
 }
示例#14
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $class = get_class($this);
     if ($class == 'Accounts') {
         if (Accounts::model()->findByPk($this->id)) {
             $this->isNewRecord = false;
         }
     }
     $a = parent::save($runValidation, $attributes);
     if ($a) {
         //if (isset($_POST['Files'])) {
         //$this->attributes = $_POST['Files'];
         $tmps = CUploadedFile::getInstancesByName('Files');
         // proceed if the images have been set
         if (isset($tmps) && count($tmps) > 0) {
             Yii::log('saved', 'info', 'app');
             // go through each uploaded image
             $configPath = Yii::app()->user->settings["company.path"];
             foreach ($tmps as $image => $pic) {
                 $img_add = new Files();
                 $img_add->name = $pic->name;
                 //it might be $img_add->name for you, filename is just what I chose to call it in my model
                 $img_add->path = "files/";
                 $img_add->parent_type = get_class($this);
                 $img_add->parent_id = $this->id;
                 // this links your picture model to the main model (like your user, or profile model)
                 $img_add->save();
                 // DONE
                 if ($pic->saveAs($img_add->getFullFilePath())) {
                     // add it to the main model now
                 } else {
                     echo 'Cannot upload!';
                 }
             }
             if (isset($_FILES)) {
                 Yii::log(print_r($_FILES, true), 'info', 'app');
                 unset($_FILES);
                 $tmps = CUploadedFile::reset();
             }
             //}
         }
     }
     //endFile
     return $a;
 }
示例#15
0
 public function calcPay()
 {
     $this->step = 1;
     $this->dates();
     $this->income_sum = Acctype::model()->findByPk(3)->getTotal($this->from_date, $this->to_date);
     $this->tax_rate = Yii::app()->user->settings['company.tax.rate'];
     //$tax
     $this->tax_sum = $this->income_sum * ($this->tax_rate / 100);
     $this->custtax_acc = Yii::app()->user->settings['company.acc.custtax'];
     $this->custtax_sum = Accounts::model()->findByPk($this->custtax_acc)->getTotal($this->from_date, $this->to_date);
     //*-1
     $this->custtax_total = Accounts::model()->findByPk($this->custtax_acc)->getTotal(0, $this->to_date);
     if ($this->custtax_total > $this->tax_sum) {
         $this->custtax_total = $this->tax_sum;
     }
     $this->tax_total = $this->tax_sum + $this->custtax_total;
     return $this->tax_total;
 }
示例#16
0
 public function actionCreate($type = 0)
 {
     $model = new FormOutcome();
     if ($type == 1) {
         $model->account_id = Yii::app()->user->settings["company.acc.payvat"];
         $model->sum = Accounts::model()->findByPk($model->account_id)->getBalance();
     }
     if ($type == 2) {
         $model->account_id = Yii::app()->user->settings["company.acc.natinspay"];
         $model->sum = Accounts::model()->findByPk($model->account_id)->getBalance();
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['FormOutcome'])) {
         $model->attributes = $_POST['FormOutcome'];
         if ($model->transaction()) {
             Yii::app()->user->setFlash('success', Yii::t('app', 'transaction Success'));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#17
0
 /**
  * Get a data provider with contacts, opportunities, and accounts 
  */
 public function getStageMemberDataProviderMixed($workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, $modelType = '')
 {
     $dateRange = self::getDateRange();
     $expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange');
     if (!is_numeric($workflowId) || !is_numeric($stage)) {
         return new CActiveDataProvider();
     }
     $records = array();
     $attrs = array();
     //        AuxLib::debugLogR ('$modelType = ');
     //        AuxLib::debugLogR ($modelType);
     //        AuxLib::debugLogR (gettype ( $modelType));
     //        AuxLib::debugLogR (strlen ($modelType));
     //        AuxLib::debugLogR ($modelType[0]);
     //        AuxLib::debugLogR ($modelType[1]);
     if (!empty($modelType)) {
         AuxLib::coerceToArray($modelType);
     }
     //        AuxLib::debugLogR ('$modelType = ');
     //        AuxLib::debugLogR ($modelType);
     // CActiveDataProviders are used for the purposes of reusing code.
     if (empty($modelType) || in_array('contacts', $modelType)) {
         $contactsDataProvider = $this->getStageMemberDataProvider('contacts', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
         $records['contacts'] = $contactsDataProvider->data;
         $attrs = array_merge($attrs, Contacts::model()->attributeNames());
     }
     if (empty($modelType) || in_array('opportunities', $modelType)) {
         $opportunitiesDataProvider = $this->getStageMemberDataProvider('opportunities', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
         $records['opportunities'] = $opportunitiesDataProvider->data;
         $attrs = array_merge($attrs, Opportunity::model()->attributeNames());
     }
     if (empty($modelType) || in_array('accounts', $modelType)) {
         $accountsDataProvider = $this->getStageMemberDataProvider('accounts', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
         $records['accounts'] = $accountsDataProvider->data;
         $attrs = array_merge($attrs, Accounts::model()->attributeNames());
     }
     // get union of attribute names
     $attrUnion = array_unique($attrs);
     $attrUnion[] = 'actionLastUpdated';
     // used to sort records
     $combinedRecords = Record::mergeMixedRecords($records, $attrUnion);
     /* 
     Sort records by the in descending order by the last time their associated workflow action 
     was updated. This allows Workflow stage listviews to be updated without reloading the 
     entire page. Every time a user drags a record from one stage to the next, placing that 
     record at the top of the target stage's list maintains the correct record ordering.
     */
     usort($combinedRecords, function ($a, $b) {
         if ($a['actionLastUpdated'] > $b['actionLastUpdated']) {
             return -1;
         } else {
             if ($a['actionLastUpdated'] < $b['actionLastUpdated']) {
                 return 1;
             } else {
                 return 0;
             }
         }
     });
     $dataProvider = new CArrayDataProvider($combinedRecords, array('pagination' => array('pageSize' => 20)));
     $dataProvider->pagination->route = '/workflow/workflow/view';
     $dataProvider->pagination->params = $_GET;
     unset($dataProvider->pagination->params['ajax']);
     return $dataProvider;
 }
示例#18
0
<?php

$this->menu = array();
$this->beginWidget('MiniForm', array('header' => Yii::t('app', "Reconciliations")));
?>

<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'intmatch-form', 'enableAjaxValidation' => false, 'clientOptions' => array('validateOnSubmit' => true)));
//$temp=CHtml::listData(Accounts::model()->findAllByAttributes(array('type' => 1)), 'id', 'name');
//$temp=CHtml::listData(Accounts::model()->findAllByAttributes(array('type' => 0)), 'id', 'name');
$temp = array_merge(Accounts::model()->findAllByAttributes(array('type' => 1)), Accounts::model()->findAllByAttributes(array('type' => 0)));
$temp = CHtml::listData($temp, 'id', 'name');
$temp[0] = Yii::t('app', 'Choose Account');
$model->account_id = 0;
//echo $form->error($model,'account_id');
echo $form->dropDownListRow($model, "account_id", $temp, array('class' => ''));
//echo $form->error($model,'account_id');
?>
<div id ="result">
</div>
<div class="row">
    <div class="col-md-3">
<?php 
//echo $form->labelEx($model, 'in_total');
echo $form->textFieldRow($model, 'in_total', array('size' => 60, 'maxlength' => 100));
//echo $form->textFieldRow($model, 'in_total');
//echo $form->labelEx($model, 'out_total');
echo $form->textFieldRow($model, 'out_total', array('size' => 60, 'maxlength' => 100));
//echo $form->error($model, 'out_total');
?>
    </div>  
示例#19
0
文件: Docs.php 项目: keyeMyria/CRM
 /**
  * Replace tokens with model attribute values.
  *
  * @param type $str Input text
  * @param X2Model $model Model to use for replacement
  * @param array $vars List of extra variables to replace
  * @param bool $encode Encode replacement values if true; use renderAttribute otherwise.
  * @return string
  */
 public static function replaceVariables($str, $model, $vars = array(), $encode = false, $renderFlag = true)
 {
     if ($encode) {
         foreach (array_keys($vars) as $key) {
             $vars[$key] = CHtml::encode($vars[$key]);
         }
     }
     $str = strtr($str, $vars);
     // replace any manually set variables
     if ($model instanceof X2Model) {
         if (get_class($model) !== 'Quote') {
             $str = Formatter::replaceVariables($str, $model, '', $renderFlag, false);
         } else {
             // Specialized, separate method for quotes that can use details from
             // either accounts or quotes.
             // There may still be some stray quotes with 2+ contacts on it, so
             // explode and pick the first to be on the safe side. The most
             // common use case by far is to have only one contact on the quote.
             $accountId = $model->accountName;
             $staticModels = array('Contact' => Contacts::model(), 'Account' => Accounts::model(), 'Quote' => Quote::model());
             $models = array('Contact' => $model->contact, 'Account' => empty($accountId) ? null : $staticModels['Account']->findByAttributes(array('nameId' => $accountId)), 'Quote' => $model);
             $attributes = array();
             foreach ($models as $name => $modelObj) {
                 $moduleRef = Modules::displayName(false, $name . "s");
                 if (empty($modelObj)) {
                     // Model will be blank
                     foreach ($staticModels[$name]->fields as $field) {
                         $attributes['{' . $moduleRef . '.' . $field->fieldName . '}'] = '';
                     }
                 } else {
                     // Insert attributes
                     foreach ($modelObj->attributes as $fieldName => $value) {
                         if ($renderFlag) {
                             $attributes['{' . $moduleRef . '.' . $fieldName . '}'] = $modelObj->renderAttribute($fieldName, false, true, $encode);
                         } else {
                             $attributes['{' . $moduleRef . '.' . $fieldName . '}'] = $modelObj->getAttribute($fieldName);
                         }
                     }
                 }
             }
             $quoteTitle = Modules::displayName(false, "Quotes");
             $quoteParams = array('{' . $quoteTitle . '.lineItems}' => $model->productTable(true), '{' . $quoteTitle . '.dateNow}' => date("F d, Y", time()), '{' . $quoteTitle . '.quoteOrInvoice}' => Yii::t('quotes', $model->type == 'invoice' ? 'Invoice' : $quoteTitle));
             // Run the replacement:
             $str = strtr($str, array_merge($attributes, $quoteParams));
             return $str;
         }
     }
     return $str;
 }
示例#20
0
if ($model->type === 'email' || $model->type === 'quote') {
    $attributes = array();
    if ($model->type === 'email') {
        foreach (X2Model::model('Contacts')->getAttributeLabels() as $fieldName => $label) {
            $attributes[$label] = '{' . $fieldName . '}';
        }
    } else {
        $accountAttributes = array();
        $contactAttributes = array();
        $quoteAttributes = array();
        foreach (Contacts::model()->getAttributeLabels() as $fieldName => $label) {
            AuxLib::debugLog('Iterating over contact attributes ' . $fieldName . '=>' . $label);
            $index = Yii::t('contacts', "{contact}", array('{contact}' => $modTitles['contact'])) . ": {$label}";
            $contactAttributes[$index] = "{associatedContacts.{$fieldName}}";
        }
        foreach (Accounts::model()->getAttributeLabels() as $fieldName => $label) {
            AuxLib::debugLog('Iterating over account attributes ' . $fieldName . '=>' . $label);
            $index = Yii::t('accounts', "{account}", array('{account}' => $modTitles['account'])) . ": {$label}";
            $accountAttributes[$index] = "{accountName.{$fieldName}}";
        }
        $Quote = Yii::t('quotes', "{quote}: ", array('{quote}' => $modTitles['quote']));
        $quoteAttributes[$Quote . Yii::t('quotes', "Item Table")] = '{lineItems}';
        $quoteAttributes[$Quote . Yii::t('quotes', "Date printed/emailed")] = '{dateNow}';
        $quoteAttributes[$Quote . Yii::t('quotes', '{quote} or Invoice', array('{quote}' => $modTitles['quote']))] = '{quoteOrInvoice}';
        foreach (Quote::model()->getAttributeLabels() as $fieldName => $label) {
            $index = $Quote . "{$label}";
            $quoteAttributes[$index] = "{" . $fieldName . "}";
        }
    }
    if ($model->type === 'email') {
        $js = 'x2.insertableAttributes = ' . CJSON::encode(array(Yii::t('contacts', '{contact} Attributes', array('{contact}' => $modTitles['contact'])) => $attributes)) . ';';
示例#21
0
 public function actionDelete()
 {
     switch ($_GET['model']) {
         // Load the respective model
         case 'Contacts':
             $model = Contacts::model()->findByPk($_GET['id']);
             break;
         case 'Actions':
             $model = Actions::model()->findByPk($_GET['id']);
             break;
         case 'Accounts':
             $model = Accounts::model()->findByPk($_GET['id']);
             break;
         default:
             $this->_sendResponse(501, sprintf('Error: Mode <b>delete</b> is not implemented for model <b>%s</b>', $_GET['model']));
             exit;
     }
     // Was a model found? If not, raise an error
     if (is_null($model)) {
         $this->_sendResponse(400, sprintf("Error: Didn't find any model <b>%s</b> with ID <b>%s</b>.", $_GET['model'], $_GET['id']));
     }
     // Delete the model
     $num = $model->delete();
     if ($num > 0) {
         $this->_sendResponse(200, sprintf("Model <b>%s</b> with ID <b>%s</b> has been deleted.", $_GET['model'], $_GET['id']));
     } else {
         $this->_sendResponse(500, sprintf("Error: Couldn't delete model <b>%s</b> with ID <b>%s</b>.", $_GET['model'], $_GET['id']));
     }
 }
示例#22
0
文件: create.php 项目: hkhateb/linet3
        CalcSum();
    }
    function addItem(last) {
        //console.log("fire!");
        var ni = document.getElementById('det');
        var num = last + 1;
        var IdName = "My" + num;
        var r = document.createElement('tr');
        var ca = document.createElement('td');
        //var cb = document.createElement('td');
        var cc = document.createElement('td');
        var cd = document.createElement('td');

        var cg = document.createElement('td');
        var accountselect='<?php 
echo str_replace("\n", "", $form->dropDownList($model, 'ops', CHtml::listData(Accounts::model()->findAll(), 'id', 'name')));
?>
'
        
        r.setAttribute("id", 'tr' + IdName);
        cg.setAttribute("id", 'Action' + IdName);//id="FormTransaction_ops"
        ca.innerHTML = accountselect.replace('id="FormTransaction_ops','id="FormTransaction_ops'+num).replace('name="FormTransaction[ops','name="FormTransaction[ops]['+num);
        
 

        cc.innerHTML = "<input type=\"text\" id=\"sumpos" + num + "\" value=\"0\" class=\"number\" name=\"FormTransaction[sumpos][" + num + "]\" size=\"6\" onblur=\"CalcSum(" + name + ")\" />";
        cd.innerHTML = "<input type=\"text\" id=\"sumneg" + num + "\" value=\"0\" class=\"number\" name=\"FormTransaction[sumneg][" + num + "]\" size=\"6\" onblur=\"CalcSum(" + name + ")\" />";

        cg.innerHTML = "<a href=\"javascript:addItem(" + num + ");\" class=\"btnadd\">הוסף</a>";

        if (last != 0) {
示例#23
0
文件: admin.php 项目: hkhateb/linet3
<?php

$this->menu = array(array('label' => Yii::t('app', 'Create Bankbook'), 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('doctype-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
$this->beginWidget('MiniForm', array('header' => Yii::t('app', "Manage Bankbooks")));
?>

 <?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'user-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
$temp = CHtml::listData(Accounts::model()->findAllByType(7), 'id', 'name');
$temp[0] = Yii::t('app', 'Choose Bank');
//$model->account_id=0;
echo $form->dropDownListRow($model, "account_id", $temp, array('class' => ''));
?>
<div id ="result">
    <?php 
echo $this->renderPartial('ajax', array('model' => $model));
?>
</div>

<?php 
$this->endWidget();
$this->endWidget();
?>

<script type="text/javascript">
    jQuery(document).ready(function(){
        $( "#Bankbook_account_id" ).change(function() {
            var value=$("#Bankbook_account_id").val();

            $.post( "<?php 
示例#24
0
 public function import()
 {
     //add warehouse
     $array = $this->read();
     //companies
     $company = $this->parseLine($array['companies'][0]);
     $prefix = $company[1];
     //echo $prefix;
     $this->saveSetting('company.name', $company[0]);
     $this->saveSetting('company.vat.id', $company[3]);
     $this->saveSetting('company.address', $company[4]);
     $this->saveSetting('company.city', $company[5]);
     $this->saveSetting('company.zip', $company[6]);
     $this->saveSetting('company.phone', $company[7]);
     $this->saveSetting('company.fax', $company[8]);
     $this->saveSetting('company.website', $company[9]);
     $this->saveSetting('company.tax.rate', $company[10]);
     $this->saveSetting('company.tax.irs', $company[11]);
     //$this->saveSetting('account.100.srctax', $company[12]);
     $this->saveSetting('company.tax.vat', $company[13]);
     //exit;
     ///*
     if (isset($array['accounts'])) {
         $this->imprtAccounts($array['accounts'], $prefix);
     }
     if (isset($array['items'])) {
         $this->imprtItems($array['items'], $prefix);
     }
     if (isset($array['docs'])) {
         $this->imprtDocs($array['docs'], $prefix);
     }
     if (isset($array['cheques'])) {
         $this->imprtCheques($array['cheques'], $prefix);
     }
     if (isset($array['docdetails'])) {
         $this->imprtDocdetails($array['docdetails'], $prefix);
     }
     if (isset($array['transactions'])) {
         $this->imprtTransactions($array['transactions'], $prefix);
     }
     if (isset($array['bankbook'])) {
         $this->imprtBankbooks($array['bankbook'], $prefix);
     }
     if (isset($array['correlation'])) {
         $this->imprtCorrelations($array['correlation'], $prefix);
     }
     //*/
     //vat rate
     $acc = Accounts::model()->findByPk(100);
     $acc->src_tax = $company[12];
     $acc->save();
     $acc = Accounts::model()->findByPk(101);
     $acc->src_tax = $company[12];
     $acc->save();
     //add warehouse
     //add genral item
     //get transaction num
     $this->saveSetting('company.transaction', Transactions::getMax() + 1);
     //get docnums
     $types = Doctype::model()->findAll();
     foreach ($types as $type) {
         $type->last_docnum = Docs::getMax($type->id);
         $type->save();
     }
     //contacthist
     //contacts??
     //tranrep??
 }
示例#25
0
 /**
  * Magic getter for {@link insertableAttributes}.
  *
  * Herein is defined how the insertable attributes are put together for each
  * different model class.
  * @return array
  */
 public function getInsertableAttributes()
 {
     if (!isset($this->_insertableAttributes)) {
         $ia = array();
         // Insertable attributes
         if ($this->targetModel !== false) {
             // Assemble the arrays to be used in putting together insertable attributes.
             //
             // What the labels will look like in the insertable attributes
             // dropdown. {attr} replaced with attribute name, {model}
             // replaced with model.
             $labelFormat = '{attr}';
             // The headers for each model/section, indexed by model class.
             $headers = array();
             // The active record objects corresponding to each model class.
             $models = array($this->modelName => $this->targetModel);
             switch ($this->modelName) {
                 case 'Quote':
                     // There will be many more models whose attributes we want
                     // to insert, so prefix each one with the model name to
                     // distinguish the current section:
                     $labelFormat = '{model}: {attr}';
                     $headers = array('Accounts' => 'Account Attributes', 'Quote' => 'Quote Attributes', 'Contacts' => 'Contact Attributes');
                     $models = array_merge($models, array('Accounts' => $this->targetModel->getLinkedModel('accountName'), 'Contacts' => $this->targetModel->contact));
                     break;
                 case 'Contacts':
                     $headers = array('Contacts' => 'Contact Attributes');
                     break;
                 case 'Accounts':
                     $labelFormat = '{model}: {attr}';
                     $headers = array_merge($headers, array('Accounts' => 'Account Attributes'));
                     break;
                 case 'Opportunity':
                     $labelFormat = '{model}: {attr}';
                     $headers = array('Opportunity' => 'Opportunity Attributes');
                     // Grab the first associated contact and use it (since that
                     // covers the most common use case of one contact, one opportunity)
                     $contactIds = explode(' ', $this->targetModel->associatedContacts);
                     if (!empty($contactIds[0])) {
                         $contact = Contacts::model()->findByPk($contactIds[0]);
                         if (!empty($contact)) {
                             $headers['Contacts'] = 'Contact Attributes';
                             $models['Contacts'] = $contact;
                         }
                     }
                     // Obtain the account info as well, if available:
                     if (!empty($this->targetModel->accountName)) {
                         $account = Accounts::model()->findAllByPk($this->targetModel->accountName);
                         if (!empty($account)) {
                             $headers['Accounts'] = 'Account Attributes';
                             $models['Accounts'] = $account;
                         }
                     }
                     break;
                 case 'Services':
                     $labelFormat = '{model}: {attr}';
                     $headers = array('Cases' => 'Case Attributes', 'Contacts' => 'Contact Attributes');
                     $models = array('Cases' => $this->targetModel, 'Contacts' => Contacts::model()->findByPk($this->targetModel->contactId));
                     break;
             }
             $headers = array_map(function ($e) {
                 return Yii::t('app', $e);
             }, $headers);
             foreach ($headers as $modelName => $title) {
                 $model = $models[$modelName];
                 if ($model instanceof CActiveRecord) {
                     $ia[$title] = array();
                     $friendlyName = Yii::t('app', rtrim($modelName, 's'));
                     foreach ($model->attributeLabels() as $fieldName => $label) {
                         $attr = trim($model->renderAttribute($fieldName, false));
                         $fullLabel = strtr($labelFormat, array('{model}' => $friendlyName, '{attr}' => $label));
                         if ($attr !== '' && $attr != '&nbsp;') {
                             $ia[$title][$fullLabel] = $attr;
                         }
                     }
                 }
             }
         }
         $this->_insertableAttributes = $ia;
     }
     return $this->_insertableAttributes;
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     // 用户数据模型
     $accountModel = Accounts::model();
     // 获取所有用户数量
     $uAllTotal = $accountModel->count();
     //获取用户分组及数量
     $unit_Total = $accountModel->getUsercount();
     $unit_num = count($unit_Total);
     $uData = json_encode($unit_Total);
     $this->render('index', array('uAllTotal' => $uAllTotal, 'uData' => $uData, 'unitTotal' => $unit_num));
 }
 private function _sendApprovalMail($model)
 {
     $account = Accounts::model()->find('t.login_name=:login_name AND t.client_id=:client_id', array(':login_name' => $model->login_name, ':client_id' => (int) $model->id));
     $subject = "Account Approved";
     $username = $account->login_name;
     $fromMail = Config::SIGNUP_FROM_MAIL_ADDR;
     $toMail = $model->email;
     $loginUrl = Yii::app()->getBaseUrl(true) . "/index.php";
     $nextBillingDate = Yii::app()->localtime->toLocalDateTime($model->next_billing_date);
     list($nextBillingDate, ) = explode(" ", $nextBillingDate);
     $body = "\r\n                <html>\r\n                <head>\r\n                  <title>{$subject}</title>\r\n                </head>\r\n                <body>\r\n                    <pre>\r\n                    Dear Customer,<br/><br/>\r\n                    Your account is authorized, you can get the benifit of trial period.<br/><br/>\r\n                    Your username is - {$username}<br/>\r\n\r\n                    You can login at - {$loginUrl}<br>\r\n                    Your trial period is going to end by - {$nextBillingDate}<br/>\r\n\r\n                    Thank you,<br/>\r\n                    {$thankYou}<br/>\r\n                    </pre>\r\n                </body>\r\n                </html>";
     Utils::queueMail($body, $subject, $fromMail, $toMail);
 }
示例#28
0
文件: Docs.php 项目: hkhateb/linet3
 private function transaction($action)
 {
     //income account -
     //vat account +
     //costmer accout +
     $precision = Yii::app()->user->getSetting('company.precision');
     $valuedate = date("Y-m-d H:m:s", CDateTimeParser::parse($this->issue_date, Yii::app()->locale->getDateFormat('yiidatetime')));
     //$num = 0;
     $tranType = $this->docType->transactionType_id;
     $round = 0;
     if (!is_null($tranType)) {
         //has trans action!
         $docAction = new Transactions();
         $docAction->num = 0;
         $docAction->account_id = $this->account_id;
         $docAction->type = $tranType;
         $docAction->linenum = 1;
         $docAction->refnum1 = $this->id;
         $docAction->refnum2 = $this->refnum_ext;
         $docAction->valuedate = $valuedate;
         $docAction->details = $this->company;
         $docAction->currency_id = $this->currency_id;
         $docAction->owner_id = $this->owner;
         if ($this->docType->isdoc) {
             $vatSum = 0;
             $sum = 0;
             foreach ($this->docDetailes as $docdetail) {
                 $refnum2 = $this->stock($docdetail->item_id, $docdetail->qty);
                 $docAction = $docdetail->transaction($docAction, $action, $this->oppt_account_id);
                 //$line++;
                 $multi = 1;
                 if (!is_null($this->oppt_account_id)) {
                     if ($oppt = Accounts::model()->findByPk($this->oppt_account_id)) {
                         $multi = $oppt->src_tax / 100;
                     }
                 }
                 $iVat = $docdetail->iTotalVat - $docdetail->iTotal;
                 $sum += ($docdetail->iTotal + $iVat) * $action;
                 $iVat *= $multi;
                 $vatSum += $iVat * $action;
             }
             //******************Discount*******************//
             if ((double) $this->discount != 0) {
                 $docdetail = $this->calcDiscount();
                 $docAction = $docdetail->transaction($docAction, $action, $this->oppt_account_id);
                 $multi = 1;
                 if (!is_null($this->oppt_account_id)) {
                     if ($oppt = Accounts::model()->findByPk($this->oppt_account_id)) {
                         $multi = $oppt->src_tax / 100;
                     }
                 }
                 $iVat = $docdetail->iTotalVat - $docdetail->iTotal;
                 $sum += ($docdetail->iTotal + $iVat) * $action;
                 $iVat *= $multi;
                 $vatSum += $iVat * $action;
             }
             //*******************Account*******************//
             $docAction = $docAction->addSingleLine($this->account_id, round($sum * -1, $precision));
             //*******************ROUND***********************//
             $diff = $sum - round($sum, $precision);
             if ($diff) {
                 //diif
                 $docAction = $docAction->addDoubleLine(6, $this->account_id, $diff);
             }
             //*******************VAT***********************//
             if ((double) $vatSum != 0) {
                 $docAction = $docAction->addSingleLine($this->docType->vat_acc_id, round($vatSum, $precision));
             }
         }
         if ($this->docType->isrecipet) {
             foreach ($this->docCheques as $docrcpt) {
                 $docAction = $docrcpt->transaction($docAction, $action, $this->account_id);
             }
         }
     }
     //Yii::app()->end();
 }
示例#29
0
 public function testMarkDuplicate()
 {
     // Confirm that markDuplicate field sets all relevant fields correctly
     Yii::app()->params->adminProf = Profile::model()->findByPk(1);
     $contact = $this->contacts('contact1');
     $this->assertEquals(0, $contact->dupeCheck);
     $this->assertEquals(1, $contact->visibility);
     $this->assertEquals('Anyone', $contact->assignedTo);
     $contact->markAsDuplicate();
     $this->assertEquals(1, $contact->dupeCheck);
     $this->assertEquals(0, $contact->visibility);
     $this->assertEquals('Anyone', $contact->assignedTo);
     $contact->markAsDuplicate('delete');
     $contact = Contacts::model()->findByPk(1);
     $this->assertEquals(null, $contact);
     // Same for accounts
     $account = $this->accounts('account1');
     $this->assertEquals(0, $account->dupeCheck);
     $this->assertEquals('Anyone', $account->assignedTo);
     $account->markAsDuplicate();
     $this->assertEquals(1, $account->dupeCheck);
     $this->assertEquals('Anyone', $account->assignedTo);
     $account->markAsDuplicate('delete');
     $account = Accounts::model()->findByPk(1);
     $this->assertEquals(null, $account);
 }
示例#30
0
 public function make()
 {
     $this->id = rand(0, 999999);
     //$this->iniArr=array('b110'=>0,'b100'=>0,'m100'=>0,'c100'=>0,'d100'=>0,'d110'=>0,'d120'=>0,);
     //$this->docArr=array(0=>0,305=>0,300=>0,);
     $bkmv = '';
     //$this->line=1;
     $yiidatetimesec = Yii::app()->locale->getDateFormat('yiidatetimesec');
     $phpdbdatetime = Yii::app()->locale->getDateFormat('phpdbdatetime');
     $from_date = date($phpdbdatetime, CDateTimeParser::parse($this->from_date . ":00", $yiidatetimesec));
     $to_date = date($phpdbdatetime, CDateTimeParser::parse($this->to_date . ":00", $yiidatetimesec));
     //$types=array(3,4,9,11,13,14);
     //accounts
     $criteria = new CDbCriteria();
     $accounts = Accounts::model()->findAll($criteria);
     $record = array('id' => 'B110', 'name' => OpenFormatType::model()->getDesc('B110'), 'count' => 0);
     foreach ($accounts as $account) {
         $this->line++;
         $bkmv .= $account->openfrmt($this->line, $from_date, $to_date);
         $record['count']++;
     }
     $this->iniArr[] = $record;
     //items
     $criteria = new CDbCriteria();
     $items = Item::model()->findAll($criteria);
     $record = array('id' => 'M100', 'name' => OpenFormatType::model()->getDesc('M100'), 'count' => 0);
     foreach ($items as $item) {
         $this->line++;
         $bkmv .= $item->openfrmt($this->line, $from_date, $to_date);
         $record['count']++;
     }
     $this->iniArr[] = $record;
     //
     //transactions
     $criteria = new CDbCriteria();
     $criteria->condition = "valuedate BETWEEN :from_date AND :to_date";
     $criteria->params = array(':from_date' => $from_date, ':to_date' => $to_date);
     $transactions = Transactions::model()->findAll($criteria);
     $record = array('id' => 'B100', 'name' => OpenFormatType::model()->getDesc('B100'), 'count' => 0);
     foreach ($transactions as $transaction) {
         $this->line++;
         $bkmv .= $transaction->openfrmt($this->line, $from_date, $to_date);
         $record['count']++;
     }
     $this->iniArr[] = $record;
     //docs
     $criteria = new CDbCriteria();
     $criteria->condition = "due_date BETWEEN :from_date AND :to_date";
     $criteria->params = array(':from_date' => $from_date, ':to_date' => $to_date);
     $docs = Docs::model()->findAll($criteria);
     //OpenFormatType::model()->getDesc('C100')
     $record = array('id' => 'C100', 'name' => OpenFormatType::model()->getDesc('C100'), 'count' => 0);
     $d110 = array('id' => 'D110', 'name' => OpenFormatType::model()->getDesc('D110'), 'count' => 0);
     $d120 = array('id' => 'D120', 'name' => OpenFormatType::model()->getDesc('D120'), 'count' => 0);
     foreach ($docs as $doc) {
         if ($doc->docType->openformat != '0') {
             $this->line++;
             $bkmv .= $doc->openfrmt($this->line, $from_date, $to_date);
             foreach ($doc->docDetailes as $detial) {
                 $this->line++;
                 $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date);
                 $d110['count']++;
             }
             foreach ($doc->docCheques as $detial) {
                 $this->line++;
                 $bkmv .= $detial->openfrmt($this->line, $from_date, $to_date);
                 $d120['count']++;
             }
             $type = $doc->getType();
             $this->docArr[$type] = isset($this->docArr[$type]) ? $this->docArr[$type] + 1 : 0;
             $this->docSumArr[$type] = isset($this->docSumArr[$type]) ? $this->docSumArr[$type] + $doc->total : $doc->total;
             $record['count']++;
         }
     }
     $this->iniArr[] = $record;
     $this->iniArr[] = $d110;
     $this->iniArr[] = $d120;
     $company = Settings::model()->findByPk('company.name');
     //A100
     $bkmv = $company->a100(1, $this->id) . $bkmv;
     //Z900
     $bkmv = $bkmv . $company->z900($this->line + 1, $this->id, $this->line + 1);
     $bkmvFile = new Files();
     $bkmvFile->name = 'bkmvdata.txt';
     $bkmvFile->path = 'openformat/';
     //
     $bkmvFile->expire = 360;
     $bkmvFile->save();
     $bkmvFile->writeFile($bkmv);
     $this->bkmvId = $bkmvFile->id;
     //A000
     $ini = $company->a000(1, $this->id, $this->line + 1);
     foreach ($this->iniArr as $line) {
         $ini .= $line['id'] . sprintf("%015d", $line['count']) . "\r\n";
     }
     //Z
     $iniFile = new Files();
     $iniFile->name = 'ini.txt';
     $iniFile->path = 'openformat/';
     //
     $iniFile->expire = 360;
     $iniFile->save();
     $iniFile->writeFile($ini);
     $this->iniId = $iniFile->id;
     return $this->id;
 }