/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Accounts();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Accounts'])) {
         $model->attributes = $_POST['Accounts'];
         $model->user_id = Yii::app()->user->id;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $rules = array('account_name' => 'required', 'account_name' => 'required|unique:accounts');
     $messages = array('account_name.required' => 'Please enter the account name !', 'account_name.unique' => 'Account Name already taken !');
     $validation = Validator::make($input, $rules, $messages);
     if ($validation->passes()) {
         $accounts = new Accounts();
         $accounts->account_name = Input::get('account_name');
         $accounts->manager_id = Session::get('manager_id');
         $accounts->save();
         return Redirect::to('/accounts');
     } else {
         return Redirect::to('/accounts/create')->withErrors($validation);
     }
 }
Ejemplo n.º 3
0
 public function createAction()
 {
     $this->view->disable();
     $status = "OK";
     $params = json_decode(file_get_contents('php://input'));
     $model = Accounts::findFirst("name='{$params->name}'");
     if ($model == null) {
         $model = new Accounts();
         $model->group = $params->group;
         $model->name = $params->name;
         $model->email = $params->email;
         $model->pm = $params->pm;
         $model->save();
     }
     echo json_encode(array("status" => $status));
 }
 public function actionCreate()
 {
     $model = new Clients();
     $account = new Accounts();
     $preference = new Preferences();
     if (isset($_POST['Clients'], $_POST['Accounts'], $_POST['Preferences'])) {
         $model->attributes = $_POST['Clients'];
         $account->attributes = $_POST['Accounts'];
         $preference->attributes = $_POST['Preferences'];
         $model->login_name = $account->login_name;
         $model->client_code = RandomGenerator::generateString(AdminGlobals::CLIENT_CODE_LENGTH);
         $model->subscription_status = "active";
         $preference->prepaid_passwd = RandomGenerator::generateString(AdminGlobals::PREPAID_PASSWD_LENGTH);
         $account->account_name = $model->client_name;
         $account->email = $model->email;
         $account->is_visible = 0;
         $valid = $model->validate();
         $valid = $account->validate() && $valid;
         $valid = $preference->validate() && $valid;
         if ($valid) {
             $transaction = Yii::app()->db->beginTransaction();
             $success = $model->save(false);
             if ($success) {
                 $account->client_id = $preference->client_id = $model->id;
             }
             $success = $success && $account->save(false);
             $success = $success && $preference->save(false);
             if ($success) {
                 $transaction->commit();
                 if (Yii::app()->request->isAjaxRequest) {
                     $this->renderPartial('view', array('model' => $this->loadModel($model->id), 'account' => $account, 'preference' => $preference), false, true);
                     Yii::app()->end();
                 }
                 $this->redirect(array('view', 'id' => $model->id));
             }
             $transaction->rollBack();
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('create', array('model' => $model, 'account' => $account, 'preference' => $preference), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model, 'account' => $account, 'preference' => $preference));
 }
 public function actionCreate()
 {
     $model = new Accounts();
     if (isset($_POST['Accounts'])) {
         $model->attributes = $_POST['Accounts'];
         if ($model->save()) {
             if (Yii::app()->request->isAjaxRequest) {
                 $this->renderPartial('view', array('model' => $this->loadModel($model->id)), false, true);
                 Yii::app()->end();
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('create', array('model' => $model), false, true);
         Yii::app()->end();
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 6
0
 public function create()
 {
     $account = new Accounts();
     $account->account_name = date("mdYGis");
     if ($account->save(false)) {
         $user = new Users();
         $user->user_name = $this->user_name;
         $user->user_lastname = $this->user_lastname;
         $user->user_email = strtolower($this->user_email);
         $user->user_admin = 1;
         $user->user_active = 1;
         $user->user_accountManager = 1;
         $user->account_id = $account->primaryKey;
         $passBeforeMD5 = $this->user_password;
         $user->user_password = md5($this->user_password);
         if ($user->save(false)) {
             /*$auth=Yii::app()->authManager;
             		$auth->assign('SuperUser',$user->primaryKey, 'return !Yii::app()->user->isGuest;', 'N;');
             		
             		$str = Yii::app()->controller->renderPartial('//templates/account/registration',array(
             			'user' => $user,
             			'passBeforeMD5' => $passBeforeMD5,
             			'applicationName' => Yii::app()->name,
             			'applicationUrl' => "http://".$_SERVER['SERVER_NAME'].Yii::app()->request->baseUrl,
             		),true);
             		
             		$subject = Yii::t('email','NewAccountRegistration');
             		
             		Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             		$mailer = new yiiPhpMailer;
             		$mailer->Ready($subject, $str, array('name'=>$user->CompleteName,'email'=>$user->user_email), Emails::PRIORITY_NORMAL);
             		*/
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 7
0
 /**	function used to create or map with existing account if the contact has mapped with an account during import
  */
 function add_create_account()
 {
     global $imported_ids;
     global $current_user;
     $acc_name = trim($this->column_fields['accountid']);
     if (!isset($acc_name) || $acc_name == '') {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Accounts();
     $query = '';
     // if user is defining the ec_account id to be associated with this contact..
     //Modified to remove the spaces at first and last in ec_account name -- after 4.2 patch 2
     $acc_name = trim(addslashes($acc_name));
     //Modified the query to get the available account only ie., which is not deleted
     $query = "select ec_account.* from ec_account WHERE accountname like '{$acc_name}%' \n\t\t\t\t\tand ec_account.deleted=0 ORDER BY accountname ";
     $result = $this->db->query($query);
     $row = $this->db->fetchByAssoc($result, -1, false);
     // we found a row with that id
     if (isset($row['accountid']) && $row['accountid'] != -1) {
         $focus->id = $row['accountid'];
     }
     // if we didnt find the ec_account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $focus->column_fields['accountname'] = $acc_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         $focus->save("Accounts");
         $acc_id = $focus->id;
         // avoid duplicate mappings:
         if (!isset($imported_ids[$acc_id])) {
             $imported_ids[$acc_id] = 1;
         }
     }
     // now just link the ec_account
     $this->column_fields["account_id"] = $focus->id;
 }
Ejemplo n.º 8
0
 public function actionAdduser()
 {
     $model = new Accounts();
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='accounts-edituser-form')
     {
     	echo CActiveForm::validate($model);
     	Yii::app()->end();
     }
     */
     if (isset($_POST['Accounts'])) {
         $model->attributes = $_POST['Accounts'];
         if ($model->validate()) {
             $newSalt = $this->generateSalt(10);
             $newPass = md5($newSalt . $model->password);
             $model->salt = $newSalt;
             $model->password = $newPass;
             $model->save();
             $this->redirect(array('index'));
         }
     }
     $this->render('adduser', array('model' => $model));
 }
Ejemplo n.º 9
0
function retrieve_account_id($account_name, $user_id)
{
    if ($account_name == "") {
        return null;
    }
    $db = PearDatabase::getInstance();
    $query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname=?";
    $result = $db->pquery($query, array($account_name)) or die("Not able to execute insert");
    $rows_count = $db->getRowCount($result);
    if ($rows_count == 0) {
        require_once 'modules/Accounts/Accounts.php';
        $account = new Accounts();
        $account->column_fields[accountname] = $account_name;
        $account->column_fields[assigned_user_id] = $user_id;
        //$account->saveentity("Accounts");
        $account->save("Accounts");
        //mysql_close();
        return $account->id;
    } else {
        if ($rows_count == 1) {
            $row = $db->fetchByAssoc($result, 0);
            //mysql_close();
            return $row["accountid"];
        } else {
            $row = $db->fetchByAssoc($result, 0);
            //mysql_close();
            return $row["accountid"];
        }
    }
}
Ejemplo n.º 10
0
 /**
  * Generates an account from the contact's company field, if that field has a value 
  */
 private static function generateAccount(Contacts $contact)
 {
     if (isset($contact->company)) {
         $account = new Accounts();
         $account->name = $contact->company;
         if ($account->save()) {
             $account->refresh();
             $contact->company = $account->nameId;
             $contact->update();
         }
     }
 }
Ejemplo n.º 11
0
 /**
 	function used to create or map with existing account if the contact has mapped with an account during import
 */
 function add_create_account()
 {
     global $imported_ids;
     global $current_user;
     require_once 'modules/Accounts/Accounts.php';
     $acc_name = trim($this->column_fields['account_id']);
     if (!isset($acc_name) || $acc_name == '') {
         return;
     }
     $arr = array();
     $focus = new Accounts();
     $query = '';
     $acc_name = trim(addslashes($acc_name));
     $query = "select  ec_account.* from ec_account WHERE accountname like '%{$acc_name}%' and deleted=0";
     $result = $this->db->query($query);
     $row = $this->db->fetchByAssoc($result, -1, false);
     if (isset($row['accountid']) && $row['accountid'] != -1) {
         $focus->id = $row['accountid'];
     }
     if (!isset($focus->id) || $focus->id == '') {
         $focus->column_fields['accountname'] = $acc_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         $focus->save("Accounts");
         $acc_id = $focus->id;
         // avoid duplicate mappings:
         if (!isset($imported_ids[$acc_id])) {
             $imported_ids[$acc_id] = 1;
         }
     }
     // now just link the ec_account
     $this->column_fields["account_id"] = $focus->id;
 }
Ejemplo n.º 12
0
 /**	function used to create or map with existing account if the contact has mapped with an account during import
  */
 function add_create_account()
 {
     global $adb;
     // global is defined in UsersLastImport.php
     global $imported_ids;
     global $current_user;
     $acc_name = $this->column_fields['account_id'];
     $adb->println("contact add_create acc=" . $acc_name);
     if (!isset($acc_name) || $acc_name == '') {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Accounts();
     $query = '';
     // if user is defining the vtiger_account id to be associated with this contact..
     //Modified to remove the spaces at first and last in vtiger_account name -- after 4.2 patch 2
     $acc_name = trim($acc_name);
     //Modified the query to get the available account only ie., which is not deleted
     $query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account, vtiger_crmentity WHERE accountname=? and vtiger_crmentity.crmid =vtiger_account.accountid and vtiger_crmentity.deleted=0";
     $result = $adb->pquery($query, array($acc_name));
     $row = $this->db->fetchByAssoc($result, -1, false);
     $adb->println("fetched account");
     $adb->println($row);
     // we found a row with that id
     if (isset($row['accountid']) && $row['accountid'] != -1) {
         $focus->id = $row['accountid'];
         $adb->println("Account row exists - using same id=" . $focus->id);
     }
     // if we didnt find the vtiger_account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $adb->println("Createing new vtiger_account");
         $focus->column_fields['accountname'] = $acc_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         //$focus->saveentity("Accounts");
         $focus->save("Accounts");
         $acc_id = $focus->id;
         $adb->println("New Account created id=" . $focus->id);
         // avoid duplicate mappings:
         if (!isset($imported_ids[$acc_id])) {
             $adb->println("inserting vtiger_users last import for vtiger_accounts");
             // save the new vtiger_account as a vtiger_users_last_import
             $last_import = new UsersLastImport();
             $last_import->assigned_user_id = $current_user->id;
             $last_import->bean_type = "Accounts";
             $last_import->bean_id = $focus->id;
             $last_import->save();
             $imported_ids[$acc_id] = 1;
         }
     }
     $adb->println("prev contact accid=" . $this->column_fields["account_id"]);
     // now just link the vtiger_account
     $this->column_fields["account_id"] = $focus->id;
     $adb->println("curr contact accid=" . $this->column_fields["account_id"]);
 }
Ejemplo n.º 13
0
function create_account($username, $sessionid, $accountname, $email, $phone, $primary_address_street, $primary_address_city, $primary_address_state, $primary_address_postalcode, $primary_address_country)
{
    if (!validateSession($username, $sessionid)) {
        return null;
    }
    global $current_user, $log, $adb;
    $log->DEBUG("Entering with data " . $username . $accountname . $email . $phone . "<br>" . $primary_address_street . $primary_address_city . $primary_address_state . $primary_address_postalcode . $primary_address_country);
    require_once "modules/Users/Users.php";
    $seed_user = new Users();
    $user_id = $seed_user->retrieve_user_id($username);
    $current_user = $seed_user;
    $current_user->retrieve_entity_info($user_id, 'Users');
    require_once "modules/Accounts/Accounts.php";
    if (isPermitted("Accounts", "EditView") == "yes") {
        $query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
        $result = $adb->pquery($query, array($accountname));
        if ($adb->num_rows($result) > 0) {
            return "Accounts";
            die;
        }
        $account = new Accounts();
        $account->column_fields['accountname'] = $accountname;
        $account->column_fields['email1'] = $email;
        $account->column_fields['phone'] = $phone;
        $account->column_fields['bill_street'] = $primary_address_street;
        $account->column_fields['bill_city'] = $primary_address_city;
        $account->column_fields['bill_state'] = $primary_address_state;
        $account->column_fields['bill_code'] = $primary_address_postalcode;
        $account->column_fields['bill_country'] = $primary_address_country;
        $account->column_fields['ship_street'] = $primary_address_street;
        $account->column_fields['ship_city'] = $primary_address_city;
        $account->column_fields['ship_state'] = $primary_address_state;
        $account->column_fields['ship_code'] = $primary_address_postalcode;
        $account->column_fields['ship_country'] = $primary_address_country;
        $account->column_fields['assigned_user_id'] = $user_id;
        $account->save('Accounts');
        if ($account->id != '') {
            return "Success";
        } else {
            return "Error while adding Account.Try again";
        }
    } else {
        return $accessDenied;
    }
}
Ejemplo n.º 14
0
$return_action = $_REQUEST['return_action'];
global $rstart;
//Added to fix 4600
$url = getBasic_Advance_SearchURL();
if (isset($_REQUEST['start']) && $_REQUEST['start'] != '') {
    $rstart = "&start=" . $_REQUEST['start'];
}
$quickedit_field = $_REQUEST['quickedit_field'];
$quickedit_value = $_REQUEST['quickedit_value'];
global $log;
$log->info("quickedit_field=" . $quickedit_field . ",quickedit_value=" . $quickedit_value);
if (isset($idlist)) {
    $recordids = explode(';', $idlist);
    $_REQUEST['ajxaction'] = "DETAILVIEW";
    for ($index = 0; $index < count($recordids); ++$index) {
        $recordid = $recordids[$index];
        $log->info("recordid=" . $recordid);
        if ($recordid == '') {
            continue;
        }
        // Save each module record with update value.
        $focus = new Accounts();
        $focus->retrieve_entity_info($recordid, 'Accounts');
        $focus->mode = 'edit';
        $focus->id = $recordid;
        $focus->column_fields[$quickedit_field] = $quickedit_value;
        $focus->save('Accounts');
        // END
    }
}
header("Location: index.php?module={$return_module}&action=" . $return_module . "Ajax&file=ListView&ajax=changestate" . $rstart . "&viewname=" . $viewid . "&errormsg=" . $errormsg . $url);
Ejemplo n.º 15
0
 $website = str_replace($whitespace, "", strtolower($account->column_fields["accountname"]));
 $account->column_fields["website"] = "www." . $website . ".com";
 $account->column_fields["bill_street"] = $street_address_array[rand(0, $street_address_count - 1)];
 $account->column_fields["bill_city"] = $city_array[rand(0, $city_array_count - 1)];
 $account->column_fields["bill_state"] = "CA";
 $account->column_fields["bill_code"] = rand(10000, 99999);
 $account->column_fields["bill_country"] = 'USA';
 $account->column_fields["ship_street"] = $account->column_fields["bill_street"];
 $account->column_fields["ship_city"] = $account->column_fields["bill_city"];
 $account->column_fields["ship_state"] = $account->column_fields["bill_state"];
 $account->column_fields["ship_code"] = $account->column_fields["bill_code"];
 $account->column_fields["ship_country"] = $account->column_fields["bill_country"];
 $key = array_rand($comboFieldArray['industry_dom']);
 $account->column_fields["industry"] = $comboFieldArray['industry_dom'][$key];
 $account->column_fields["account_type"] = "Customer";
 $account->save("Accounts");
 $account_ids[] = $account->id;
 if ($i > 3) {
     $freetag = $adb->getUniqueId('vtiger_freetags');
     $query = "insert into vtiger_freetags values (?,?,?)";
     $qparams = array($freetag, $cloudtag[1], $cloudtag[1]);
     $res = $adb->pquery($query, $qparams);
     $date = $adb->formatDate(date('YmdHis'), true);
     $query_tag = "insert into vtiger_freetagged_objects values (?,?,?,?,?)";
     $tag_params = array($freetag, 1, $account->id, $date, Accounts);
     $result = $adb->pquery($query_tag, $tag_params);
 }
 //Create new opportunities
 $opp = new Potentials();
 $opp->column_fields["assigned_user_id"] = $assigned_user_id;
 $opp->column_fields["potentialname"] = $account_name . " - 1000 units";
Ejemplo n.º 16
0
    $value = convertToDollar($_REQUEST['annual_revenue'], $rate);
    $focus->column_fields['annual_revenue'] = $value;
}
if ($_REQUEST['assigntype'] == 'U') {
    $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id'];
} elseif ($_REQUEST['assigntype'] == 'T') {
    $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id'];
}
//When changing the Account Address Information  it should also change the related contact address - dina
if ($focus->mode == 'edit' && $_REQUEST['address_change'] == 'yes') {
    $query = "update vtiger_contactaddress set mailingcity=?,mailingstreet=?,mailingcountry=?,mailingzip=?,mailingpobox=?,mailingstate=?,othercountry=?,othercity=?,otherstate=?,otherzip=?,otherstreet=?,otherpobox=?  where contactaddressid in (select contactid from vtiger_contactdetails where accountid=?)";
    $params = array($focus->column_fields['bill_city'], $focus->column_fields['bill_street'], $focus->column_fields['bill_country'], $focus->column_fields['bill_code'], $focus->column_fields['bill_pobox'], $focus->column_fields['bill_state'], $focus->column_fields['ship_country'], $focus->column_fields['ship_city'], $focus->column_fields['ship_state'], $focus->column_fields['ship_code'], $focus->column_fields['ship_street'], $focus->column_fields['ship_pobox'], $focus->id);
    $adb->pquery($query, $params);
}
//Changing account address - Ends
$focus->save("Accounts");
$return_id = $focus->id;
$parenttab = getParentTab();
if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") {
    $return_module = vtlib_purify($_REQUEST['return_module']);
} else {
    $return_module = "Accounts";
}
if (isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") {
    $return_action = vtlib_purify($_REQUEST['return_action']);
} else {
    $return_action = "DetailView";
}
if (isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") {
    $return_id = vtlib_purify($_REQUEST['return_id']);
}
Ejemplo n.º 17
0
 public function readBkmv()
 {
     //sort
     $this->sortBkmvFile();
     //skip for testing
     //
     //new company
     //get perm from ini
     //if (substr($line,395,1)=='2')
     //    $encoding="ibm862";
     //else
     $encoding = "windows-1255";
     //$encoding="ibm862";
     Yii::log('start Openimport', 'info', 'app');
     //$bkmv = $yiiBasepath."/files/".$configPath."/openformt/bkmvdata.txt-sorted";
     $bkmv = $this->bkmvFile . "-sorted";
     $suc = array();
     $suc['B110'] = 0;
     $suc['A100'] = 0;
     $suc['B100'] = 0;
     $suc['C100'] = 0;
     $suc['M100'] = 0;
     $suc['D110'] = 0;
     $suc['D120'] = 0;
     $suc['Z900'] = 0;
     $analze = array();
     $analze['B110'] = 0;
     $analze['A100'] = 0;
     $analze['B100'] = 0;
     $analze['C100'] = 0;
     $analze['M100'] = 0;
     $analze['D110'] = 0;
     $analze['D120'] = 0;
     $analze['Z900'] = 0;
     $accType = 200;
     //DELETE FROM `qwe_docCheques` WHERE 1;DELETE FROM `qwe_docDetails` WHERE 1;DELETE FROM `qwe_accounts` WHERE 1;DELETE FROM `qwe_items` WHERE 1;DELETE FROM `qwe_docs` WHERE 1;
     if ($fp = fopen($bkmv, 'r')) {
         while ($line = fgets($fp)) {
             @($line = iconv($encoding, "UTF-8//IGNORE", $line));
             //$line=utf8_encode($line);
             $type = substr($line, 0, 4);
             //$obj=$this->readline($line,$type);
             $obj = true;
             if (!$obj) {
                 //$suc[$type]--;
             } else {
                 //foreach ($obj as &$value)
                 //	if ($encoding=="ibm862")
                 //		$value = iconv("ISO-8859-8", "UTF-8", hebrev(iconv("UTF-8", "ISO-8859-8", $value)));
                 if ($type == 'B110') {
                     //Acc Haeder
                     /* Account Import */
                     $acc = new Accounts();
                     $acc->readLine($line, $type);
                     if (isset($this->accTypeIndex[$acc->type])) {
                         $this->accDesc[$acc->type] = $this->accDesc[$acc->type] . "," . $acc->name;
                     } else {
                         $this->accDesc[$acc->type] = $acc->name;
                         $this->accTypeIndex[$acc->type] = $accType;
                         $accType++;
                     }
                     $acc->type = $this->accTypeIndex[$acc->type];
                     $acc->save();
                     //get new acc index save old
                     unset($acc);
                     //*/
                 }
                 if ($type == 'M100') {
                     //Item In Stock
                     $item = new Item();
                     $item->category_id = 0;
                     $item->parent_item_id = 0;
                     $item->isProduct = 0;
                     $item->profit = 0;
                     $item->stockType = 0;
                     $item->readLine($line, $type);
                     $item->save();
                     unset($item);
                     //*/
                 }
                 if ($type == 'C100') {
                     //Doc Haeder
                     //return "done!";
                     //Yii::app()->end();
                     //find type
                     //global $DocOpenType;
                     $doc = new Docs();
                     $doc->readLine($line, $type);
                     $doc->status = 1;
                     //needtoChange
                     //Yii::log($doc,'info','app');
                     $doc->save();
                     unset($doc);
                     /*
                     					if ((isset($DocOpenType[$obj['doctype']])) && (isset($accIndex[$obj['account']]))){
                     						$obj['doctype']=$DocOpenType[$obj['doctype']];
                     						$doc=new document($obj['doctype']);
                     						$stype=$obj['doctype'];
                     						foreach($obj as $key=>$value){
                     							$doc->$key=$value;//print "$key <br />";
                     						}
                     						$doc->account=$accIndex[$doc->account];
                     						//search for old acc index
                     						if (isset($doc->rcptdetials)) unset($doc->rcptdetials);
                     						if (isset($doc->docdetials)) unset($doc->docdetials);
                     						
                     						if($check){
                     							if((strtotime($doc->issue_date)>$begindmy)&&(strtotime($doc->issue_date)<$enddmy))
                     								$docIndex[$stype.$obj["docnum"]]=$doc->newDocument();
                     							//print "we are chking!";
                     						}else{
                     							$docIndex[$stype.$obj["docnum"]]=$doc->newDocument();
                     						}
                     						//get new doc index save old
                     						unset($doc);
                     					}*/
                 }
                 if ($type == 'D110') {
                     //Doc Detial
                     $docdetial = new Docdetails();
                     $docdetial->readLine($line, $type);
                     //Yii::log($docdetial,'info','app');
                     $docdetial->save();
                     unset($docdetial);
                     /*
                     					global $DocOpenType;
                     					$stype=$DocOpenType[$obj['doctype']];
                     					if (isset($docIndex[$stype.$obj["num"]])){		
                     						$docdetial=new documentDetail;
                     						$docdetial->price=$obj['price'];
                     						unset($obj['doctype']);
                     						unset($obj['price']);
                     						
                     						foreach($obj as $key=>$value){
                     							$docdetial->{$key}=$value;//print "$key <br />";
                     							
                     						}
                     						
                     						$docdetial->num=$docIndex[$stype.$obj["num"]];	
                     						$docdetial->newDetial();
                     						
                     						//search for old doc index
                     						//die;
                     						//update to new index
                     						unset($docdetial);
                     					}//*/
                 }
                 if ($type == 'D120') {
                     //Kaballa Detial
                     $rcptdetial = new Doccheques();
                     $rcptdetial->readLine($line, $type);
                     Yii::log($rcptdetial, 'info', 'app');
                     $rcptdetial->save();
                     unset($rcptdetial);
                     /*
                     					global $DocOpenType;
                     					$stype=$DocOpenType[$obj['doctype']];
                     					if (isset($docIndex[$stype.$obj["refnum"]])){
                     						$rcptdetial=new receiptDetail();
                     						//$stype=$DocOpenType[$obj['doctype']];
                     						$rcptdetial->sum=(float)$obj['sum'];
                     						unset($obj['sum']);
                     						unset($obj['doctype']);
                     						foreach($obj as $key=>$value){
                     							$rcptdetial->$key=$value;
                     						}
                     						$rcptdetial->refnum=$docIndex[$stype.$obj["refnum"]];	
                     						$rcptdetial->newDetial();
                     						//search for old doc index
                     						//update to new index
                     						unset($rcptdetial);
                     					}*/
                 }
                 if ($type == 'B100') {
                     //Move Recored
                     $transaction = new Transactions();
                     $transaction->readLine($line, $type);
                     $transaction->save();
                     //Yii::log($transaction,'info','app');
                     unset($transaction);
                     /*
                     					//print $obj['value'].":".$obj['type'];
                     					global $openTransType;
                     					
                     					if (isset($accIndex[$obj['account']])){
                     						$bsum= $obj['sum'];
                     						if($obj['value']==1)
                     							$bsum= -1 * $obj['sum'];
                     						//print $bsum."<br />\n";
                     						$usum=$bsum*-1;
                     						
                     						$uaccount=$obj['account1'];
                     						$stype=$openTransType[$obj['type']];
                     						unset($obj['sum']);
                     						unset($obj['value']);
                     						unset($obj['account1']);
                     						//adam:! need to reset type of action!
                     						
                     						$transaction=new transaction;
                     						
                     						foreach($obj as $key=>$value){
                     							$transaction->$key=$value;//print "$key <br />";
                     						}
                     						$transaction->type=$stype;
                     						$transaction->sum=$bsum;
                     						$transaction->account=$accIndex[$obj['account']];
                     						
                     						if($check){
                     								if((strtotime($transaction->date)>$begindmy)&&(strtotime($transaction->date)<$enddmy)){
                     									// "gone";
                     									$transaction->newTransactions();
                     								}
                     								//print "gone2";	
                     							}else{
                     								//print "gone1";
                     								$transaction->newTransactions();
                     							}
                     						unset($transaction);
                     					}//*/
                 }
                 unset($obj);
                 $suc[$type]++;
             }
             $analze[$type]++;
             //if ($analze[$type]>100)	break;
         }
         Yii::log("End OpenImport", 'info', 'app');
         //print_r($docIndex);
         //end loop
         //print_r($accIndex);
     } else {
         print _("error cant open file!");
     }
 }