Exemplo n.º 1
0
 /**
  * @param : int $id
  * @param : array $data
  * @return boolean
  */
 public static function update($id, $data)
 {
     if (!is_array($data) || !count($data)) {
         return;
     }
     $shipFromData = $data['shipFrom'];
     $shipToData = $data['shipTo'];
     $itemData = $data['item'];
     $companyData = $data['company'];
     $query = "SELECT * FROM `order` WHERE id = :id";
     $param = array('id' => $id);
     $result = DB::select($query, $param);
     if (count($result) > 0) {
         $order = $result[0];
         $shipToId = $order->ship_to ? $order->ship_to : 0;
         $shipFromId = $order->ship_from ? $order->ship_from : 0;
         $itemId = $order->item_id ? $order->item_id : 0;
         $companyId = $order->company_id ? $order->company_id : 0;
         ShipFrom::update($shipFromId, $shipFromData);
         ShipTo::update($shipToId, $shipToData);
         Item::update($itemId, $itemData);
         Company::update($companyId, $companyData);
         return true;
     }
 }
Exemplo n.º 2
0
 /**
  * create new company & user as creator & admin
  */
 public function register()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         //create company first
         $company = new Company();
         $company->name = $this->name;
         $company->country = $this->country;
         $company->phone = $this->phone;
         if (!$company->save()) {
             $transaction->rollback();
             return false;
         }
         //create user
         $user = new User();
         $user->username = $this->username;
         $user->password = $user->encrypt($this->password);
         $user->password_repeat = $this->password_repeat;
         $user->email = $this->email;
         $user->company_id = $company->id;
         $user->create_time_utc = $user->update_time_utc = time();
         if (!$user->save(false)) {
             $transaction->rollback();
             return false;
         }
         $company->owner_id = $company->create_user_id = $company->update_user_id = $user->id;
         if (!$company->update()) {
             $transaction->rollback();
             return false;
         }
         $user->create_user_id = $user->update_user_id = $user->id;
         if (!$user->update()) {
             $transaction->rollback();
             return false;
         }
         //create default product folder
         $defaultProductFolder = new ProductFolder();
         $defaultProductFolder->name = 'Main Folder';
         $defaultProductFolder->parent_id = 0;
         $defaultProductFolder->company_id = $company->id;
         if (!$defaultProductFolder->save()) {
             $transaction->rollback();
             return false;
         }
         $transaction->commit();
         return true;
     } catch (Exception $ex) {
         $transaction->rollback();
         return false;
     }
 }
Exemplo n.º 3
0
            header('Location:../user/');
        } else {
            header('Location:register.php');
        }
        break;
    case "update":
        $mUser = new User();
        $mCompany = new Company($mUser->getCompany());
        //$name = $_POST['name'];
        //$tin_number = $_POST['tin_number'];
        $address_1 = $_POST['address_1'];
        $address_2 = $_POST['address_2'];
        $landmark = $_POST['landmark'];
        $city = $_POST['city'];
        $state = $_POST['state'];
        $pincode = $_POST['pincode'];
        $email = $_POST['email'];
        $fax = $_POST['fax'];
        $phone = $_POST['phone'];
        $website = $_POST['website'];
        $description = "";
        if ($mCompany->update($address_1, $address_2, $landmark, $city, $state, $pincode, $phone, $fax, $email, $website, $description)) {
            //echo 'changes completed..';
            echo "<script>alert('Updated Successfully!!!')</script>";
            echo "<script>window.location.href = '../company/'</script>";
        } else {
            echo "<script>alert('Some problem occured!!!')</script>";
            echo "<script>window.location.href = '../company/'</script>";
        }
        break;
}
$GeneralObj->getRequestVars();
$companyObj->setAllVar();
if ($mode == "Add") {
    # echo "<pre>";  print_r($_FILES) ; exit;
    $redirect_file = "index.php?file=m-companyadd";
    $GeneralObj->checkDuplicate('iCompanyId', 'Company', array('vCompanyCodeId'), $redirect_file, "Organization ID Already Exists ", $iCompanyId);
    $GeneralObj->checkDuplicate('iCompanyId', 'Company', array('vCompanyName'), $redirect_file, "Organization Name Already Exists ", $iCompanyId);
    $GeneralObj->checkDuplicate('iCompanyId', 'Company', array('vEmail'), $redirect_file, "Email Already Exists ", $iCompanyId);
    // $userObj->setdCreated($dCreated);
    $iCompanyId = $companyObj->insert();
    $group = new SubGroup();
    $group->createDefaultGroup($iCompanyId);
    $msg = MSG_ADD;
    $url = 'index.php?file=Company&AX=Yes&var_msg=' . $msg;
    header("Location:" . $url);
    exit;
} else {
    if ($mode == "Update") {
        $update_sql = "UPDATE SubGroup sg SET sg.eStatus = '" . $eStatus . "'\n\t\t\tWHERE sg.iCompanyId IN(" . $iCompanyId . ")";
        $obj->sql_query($update_sql);
        $redirect_file = "index.php?file=m-companyadd&mode=" . $mode . "&iCompanyId=" . $iCompanyId . "";
        $GeneralObj->checkDuplicate('iCompanyId', 'Company', array('vCompanyCodeId'), $redirect_file, "Organization ID Already Exists ", $iCompanyId);
        $GeneralObj->checkDuplicate('iCompanyId', 'Company', array('vCompanyName'), $redirect_file, "Organization Name Already Exists ", $iCompanyId);
        $GeneralObj->checkDuplicate('iCompanyId', 'Company', array('vEmail'), $redirect_file, "Email Already Exists ", $iCompanyId);
        $companyObj->update($iCompanyId);
        $msg = MSG_UPDATE;
        $url = 'index.php?file=Company&AX=Yes&var_msg=' . $msg;
        header("Location:" . $url);
        exit;
    }
}
Exemplo n.º 5
0
<?php

include_once "../../../../../../libraries/aces/models/companypage.php";
// echo json_encode('xxx');
$_POST['id'] = $_POST['id'];
$_POST['userid'] = $_POST['userid'];
$_POST['company_name'] = $_POST['company_name'];
// $_POST['email'] = $_POST['email'];
$_POST['about'] = $_POST['about'];
$_POST['website'] = $_POST['website'];
$_POST['specialties'] = $_POST['specialties'];
$_POST['industry'] = $_POST['industry'];
$_POST['locations'] = $_POST['locations'];
$_POST['size'] = $_POST['size'];
$_POST['type'] = $_POST['type'];
$_POST['status'] = $_POST['status'];
$cmp = new Company($user->id);
$data = $cmp->update($_POST);
// echo json_encode($data);
// print_r($data);
// foreach($data as $edudata){
// echo json_encode($edudata);
// }
Exemplo n.º 6
0
    if (empty($_POST["lastname"])) {
        system\Helper::arcAddMessage("danger", "Lastname cannot be empty");
        return;
    }
    $test = User::getByEmail($_POST["email"]);
    if ($user->id == 0 && $test->id != 0) {
        system\Helper::arcAddMessage("danger", "User already exists with this email address");
        return;
    }
    if ($user->id == 0 && empty($_POST["password"])) {
        system\Helper::arcAddMessage("danger", "New users must have a password");
        return;
    }
    if (!empty($_POST["company"])) {
        $comp = Company::getByName(ucwords($_POST["company"]));
        if ($comp->id == 0) {
            $comp = new Company();
            $comp->name = ucwords($_POST["company"]);
            $comp->update();
        }
        $user->addToCompany($comp->id);
    }
    if ($_POST["enabled"] == "true") {
        $user->enabled = 1;
    } else {
        $user->enabled = 0;
    }
    $user->email = strtolower($_POST["email"]);
    $user->update();
    system\Helper::arcAddMessage("success", "Changes saved");
}
Exemplo n.º 7
0
 public function updateCompany($data)
 {
     $company = new Company($this->getUser()->id);
     $data = $company->update($data);
     return $data;
 }
Exemplo n.º 8
0
        $data = json_decode($body);
        $data->id = $id;
        $user->update($data);
    } else {
        echo "<script>window.location='../../'</script>";
    }
});
$app->get('/company', function () use($company) {
    $company->get();
});
$app->put('/company/:id', function () use($company, $app) {
    if (isset($_SESSION['app']) && isset($_COOKIE['app'])) {
        $request = $app->request();
        $body = $request->getBody();
        $data = json_decode($body);
        $company->update($data);
    } else {
        echo "<script>window.location='../../'</script>";
    }
});
$app->post('/email', function () use($email) {
    $email->sendEmail();
});
$app->get('/email', function () use($email) {
    if (isset($_SESSION['app']) && isset($_COOKIE['app'])) {
        $email->get();
    } else {
        echo "<script>window.location='../../'</script>";
    }
});
$app->post('/email/config', function () use($email) {
Exemplo n.º 9
0
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('POST /v1/main/company', function () {
    try {
        $object = Company::insert();
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/company/@id', function ($id) {
    try {
        $object = Company::update($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('DELETE /v1/main/company/@id', function ($id) {
    try {
        $object = Company::delete($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
//=============================================================================
//CompanyInfo
Exemplo n.º 10
0
     return View::create('companies/edit', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/companies/edit/(:num)', function ($id) {
     $input = Input::get(array('title', 'slug', 'description'));
     $validator = new validator($input);
     $validator->check('title')->is_max(3, __('companies.title_missing'));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/companies/edit/' . $id);
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     Company::update($id, $input);
     Extend::process('company', $id);
     Notify::successs(__('companies.update'));
     return Response::redirect('admin/companies/edit/' . $id);
 });
 Route::get('admin/companies/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['fields'] = Extend::fields('company');
     return View::create('companies/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/companies/add', function () {
     $input = Input::get(array('title', 'slug', 'description'));
     $validator = new validator($input);
     $validator->check('title')->is_max(3, __('companies.title_missing'));
     if ($errors = $validator->errors()) {
Exemplo n.º 11
0
             Company::update($company);
         } else {
             Company::insert($company);
         }
     } else {
         //分支将会被移出
         foreach ($_REQUEST as $key => $value) {
             $key = strtolower($key);
             $nokeys = array("type", "module", "action");
             if (!in_array($key, $nokeys)) {
                 $company = new Company();
                 $company->content = empty($value) ? "" : $value;
                 $company->companyKey = $key;
                 if ($action == "update" && Company::exist($key)) {
                     //存在,并且需要更新
                     Company::update($company);
                 } else {
                     Company::insert($company);
                 }
             }
         }
     }
 } else {
     if ($action == "del") {
         $id = isset($_REQUEST["companyId"]) ? $_REQUEST["companyId"] : 0;
         //是否允许重置添
         $company = new Company(_NONE);
         $company->id = $id;
         Company::delete($company);
     }
 }