本文整理汇总了PHP中Contract类的典型用法代码示例。如果您正苦于以下问题:PHP Contract类的具体用法?PHP Contract怎么用?PHP Contract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contract类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: transform
/**
* Transforms an object (contract) to a string (name).
*
* @param Contract|null $entity
* @return string
*/
public function transform($entity)
{
if (null === $entity) {
return "";
}
return $entity->getNumber() . ' / ' . $entity->getDoor()->getLocation() . ' / ' . $entity->getDoor()->getType();
}
开发者ID:jlm-entreprise,项目名称:contract-bundle,代码行数:13,代码来源:ContractToStringTransformer.php
示例2: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $DB, $CFG_GLPIG;
if (!Session::haveRight("contract", "r")) {
return false;
}
$type = $item->getType();
$ID = $item->getField('id');
$con = new Contract();
$query = "SELECT *\n FROM `glpi_contracts_items`\n WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = $j = 0;
$pdf->setColumnsSize(100);
if ($number > 0) {
$pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
$pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
$pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
$i++;
while ($j < $number) {
$cID = $DB->result($result, $j, "contracts_id");
$assocID = $DB->result($result, $j, "id");
if ($con->getFromDB($cID)) {
$pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
}
$j++;
}
} else {
$pdf->displayTitle("<b>" . __('No item found') . "</b>");
}
$pdf->displaySpace();
}
开发者ID:geldarr,项目名称:hack-space,代码行数:32,代码来源:contract_item.class.php
示例3: actionLoadContractsSampler
public function actionLoadContractsSampler()
{
if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
throw new NotSupportedException();
}
for ($i = 0; $i < 11; $i++) {
$owner = Yii::app()->user->userModel;
$name = 'Mass Delete ' . $i;
$currencies = Currency::getAll();
$currencyValue = new CurrencyValue();
$currencyValue->value = 500.54;
$currencyValue->currency = $currencies[0];
$contract = new Contract();
$contract->owner = $owner;
$contract->name = $name;
$contract->amount = $currencyValue;
$contract->closeDate = '2011-01-01';
//eventually fix to make correct format
$contract->stage->value = 'Negotiating';
$saved = $contract->save();
if (!$saved) {
throw new NotSupportedException();
}
}
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:DemoController.php
示例4: testB
public function testB()
{
$testValue1 = 100;
$testValue2 = 'red';
$testValue3 = array('name' => 'John Smith', 'age' => 30);
$contract = new Contract(array('test1' => array('data' => $testValue1, 'definition' => 'integer'), 'test2' => array('data' => $testValue2, 'definition' => array('length' => 3, 'in' => array('red', 'green', 'blue'))), 'test3' => array('data' => $testValue3, 'definition' => array('arraylist', 'element' => array('age' => array('integer', 'lessThan' => 29), 'name' => array('alpha', 'in' => array('John Doe', 'Jane Smith')))))));
$contract->metOrThrow();
}
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:8,代码来源:Array_Notation.php
示例5: filterByValidUser
public function filterByValidUser($usersData)
{
/* Before filtering the data, establish the agreement for the method parameters. */
$contract = new Contract();
$contract->term('usersData')->arraylist();
$contract->metOrThrow();
/* Users data must be an array of elements, each element an array itself, with an id, name, registered date, and active boolean true.
Allowed fields to be returned are the defined elements: id, name, registered, active. */
$contract->term('usersData')->elements()->arraylist()->element('id')->id()->end()->element('name')->optional()->alpha()->end()->element('registered')->datetime()->end()->element('active')->boolean()->equals(true)->end();
$filteredData = $contract->term('usersData')->data();
return $filteredData;
}
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:12,代码来源:Filter.php
示例6: createUser
public function createUser($userId, $userData)
{
/* Define Contract Requirements for Model Data */
$contract = new Contract();
$contract->term('userId')->id();
$contract->term('userData')->arraylist()->element('type')->in(array('member', 'administrator'))->end()->element('username')->alphaNumeric()->length(8, 16)->end()->element('name')->required()->end()->element('address')->required()->end()->element('city')->required()->end()->element('state')->length(2)->end()->element('zip')->length(5, 10)->end()->element('country')->required()->end()->element('email')->email()->end()->element('phone')->phone()->end()->element('fax')->optional()->phone()->end()->element('photo')->optional()->file()->end()->element('website')->optional()->url()->end()->element('registered')->datetime()->end()->element('active')->boolean()->end();
$contract->metOrThrow();
/* Follow w/ Basic MySQL Query */
$rows = array();
/* $select = "SELECT * FROM user WHERE id = {$userId}";
while($row = mysql_query($select)) $rows[] = $row; */
return $rows;
}
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:13,代码来源:Model.php
示例7: can
/**
* Check right on an contract - overloaded to check max_links_allowed
*
* @param $ID ID of the item (-1 if new item)
* @param $right Right to check : r / w / recursive
* @param $input array of input data (used for adding item)
*
* @return boolean
**/
function can($ID, $right, &$input = NULL)
{
if ($ID < 0) {
// Ajout
$contract = new Contract();
if (!$contract->getFromDB($input['contracts_id'])) {
return false;
}
if ($contract->fields['max_links_allowed'] > 0 && countElementsInTable($this->getTable(), "`contracts_id`='" . $input['contracts_id'] . "'") >= $contract->fields['max_links_allowed']) {
return false;
}
}
return parent::can($ID, $right, $input);
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:23,代码来源:contract_item.class.php
示例8: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
UserTestHelper::createBasicUser('jim');
AllPermissionsOptimizationUtil::rebuild();
ContractTestHelper::createContractStagesIfDoesNotExist();
ContractTestHelper::createContractSourcesIfDoesNotExist();
$currencies = Currency::getAll();
//Make Contracts for testing chart data.
$currencyValue = new CurrencyValue();
$currencyValue->value = 200;
$currencyValue->currency = $currencies[0];
$contract = new Contract();
$contract->owner = $super;
$contract->name = 'abc1';
$contract->amount = $currencyValue;
$contract->closeDate = '2011-01-01';
$contract->stage->value = 'Negotiating';
$contract->source->value = 'Outbound';
assert($contract->save());
// Not Coding Standard
$currencyValue = new CurrencyValue();
$currencyValue->value = 350;
$currencyValue->currency = $currencies[0];
$contract = new Contract();
$contract->owner = $super;
$contract->name = 'abc2';
$contract->amount = $currencyValue;
$contract->closeDate = '2011-01-01';
$contract->stage->value = 'Negotiating';
$contract->source->value = 'Trade Show';
assert($contract->save());
// Not Coding Standard
$currencyValue = new CurrencyValue();
$currencyValue->value = 100;
$currencyValue->currency = $currencies[0];
$contract = new Contract();
$contract->owner = $super;
$contract->name = 'abc2';
$contract->amount = $currencyValue;
$contract->closeDate = '2011-01-01';
$contract->stage->value = 'Verbal';
$contract->source->value = 'Trade Show';
assert($contract->save());
// Not Coding Standard
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:49,代码来源:ContractsChartDataProviderTest.php
示例9: testSaveAndRetrievePortlet
public function testSaveAndRetrievePortlet()
{
$user = UserTestHelper::createBasicUser('Billy');
$contracts = Contract::getByName('superOpp');
$portlet = new Portlet();
$portlet->column = 2;
$portlet->position = 5;
$portlet->layoutId = 'Test';
$portlet->collapsed = true;
$portlet->viewType = 'ContractsForContactRelatedList';
$portlet->serializedViewData = serialize(array('title' => 'Testing Title'));
$portlet->user = $user;
$this->assertTrue($portlet->save());
$portlet = Portlet::getById($portlet->id);
$params = array('controllerId' => 'test', 'relationModuleId' => 'test', 'relationModel' => $contracts[0], 'redirectUrl' => 'someRedirect');
$portlet->params = $params;
$unserializedViewData = unserialize($portlet->serializedViewData);
$this->assertEquals(2, $portlet->column);
$this->assertEquals(5, $portlet->position);
$this->assertEquals('Testing Title', $portlet->getTitle());
$this->assertEquals(false, $portlet->isEditable());
$this->assertEquals('Test', $portlet->layoutId);
//$this->assertEquals(true, $portlet->collapsed); //reenable once working
$this->assertEquals('ContractsForContactRelatedList', $portlet->viewType);
$this->assertEquals($user->id, $portlet->user->id);
$view = $portlet->getView();
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:27,代码来源:ContractsRelatedListPortletTest.php
示例10: showGlobalView
/**
* Show the central global view
**/
static function showGlobalView()
{
$showticket = haveRight("show_all_ticket", "1");
echo "<table class='tab_cadre_central'><tr>";
echo "<td class='top'><br>";
echo "<table >";
if ($showticket) {
echo "<tr><td class='top' width='450px'>";
Ticket::showCentralCount();
echo "</td></tr>";
}
if (haveRight("contract", "r")) {
echo "<tr><td class='top' width='450px'>";
Contract::showCentral();
echo "</td></tr>";
}
echo "</table></td>";
if (haveRight("logs", "r")) {
echo "<td class='top' width='450px'>";
//Show last add events
Event::showForUser($_SESSION["glpiname"]);
echo "</td>";
}
echo "</tr></table>";
if ($_SESSION["glpishow_jobs_at_login"] && $showticket) {
echo "<br>";
Ticket::showCentralNewList();
}
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:32,代码来源:central.class.php
示例11: find_contract_team
public function find_contract_team()
{
$conts = Contract::find_by_sql("SELECT * FROM contracts WHERE player={$this->id} AND expiry>" . time() . " AND term=0 ORDER BY date_of_reg DESC");
if (isset($conts)) {
return Team::find_by_id($conts[0]->team);
} else {
return NULL;
}
}
开发者ID:kunal-bajpai,项目名称:gfa,代码行数:9,代码来源:player.php
示例12: del
function del($ctx)
{
$id = intval($_GET['id']);
$contract = Contract::get($id);
if ($contract) {
$contract->set_del();
}
_redirect(_list_url());
}
开发者ID:zxw5775,项目名称:yuhunclub,代码行数:9,代码来源:contract.php
示例13: delete
/**
*
* @param type $_id
* @return \Illuminate\Http\Response Description
*/
public function delete($_id)
{
$contract = Contract::find($_id);
$response = array('status' => false, '_id' => $_id);
if ($contract->delete()) {
$response['status'] = true;
}
$headers = array('Content-type' => 'application/json');
return \Illuminate\Http\Response::create($response, 200, $headers);
}
开发者ID:ma7euus,项目名称:test,代码行数:15,代码来源:ContractController.php
示例14: scoreOnSaveModel
/**
* (non-PHPdoc)
* @see GamificationRules::scoreOnSaveModel()
*/
public function scoreOnSaveModel(CEvent $event)
{
parent::scoreOnSaveModel($event);
if (array_key_exists('value', $event->sender->stage->originalAttributeValues) && $event->sender->stage->value == Contract::getStageClosedWonValue()) {
$scoreType = static::SCORE_TYPE_WIN_CONTRACT;
$category = static::SCORE_CATEGORY_WIN_CONTRACT;
$gameScore = GameScore::resolveToGetByTypeAndPerson($scoreType, Yii::app()->user->userModel);
$gameScore->addValue();
$saved = $gameScore->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
GamePointUtil::addPointsByPointData(Yii::app()->user->userModel, static::getPointTypeAndValueDataByCategory($category));
}
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:19,代码来源:ContractGamificationRules.php
示例15: login
public function login()
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
/* Hypothetical Data */
$loginUserEmail = $_REQUEST['email'];
$loginUserPass = $_REQUEST['pass'];
$loginUserIp = $_SERVER['REMOTE_ADDR'];
$loginDateTime = date('Y-m-d H:i:s');
try {
$contract = new Contract();
$contract->term('userEmail', $loginUserEmail)->email()->metOrThrow();
$contract->term('userPass', $loginUserPass)->alphaNumeric()->length(8, 16)->metOrThrow();
$contract->term('userIp', $loginUserPass)->ip()->metOrThrow();
$contract->term('dateTime', $loginDateTime)->datetime()->metOrThrow();
/* Get User For Login */
$user = $userModel->getUser($userEmail, $userPass);
$contract->term('user', $user)->arraylist()->element('id')->id()->end()->element('active')->equals(1)->end()->metOrThrow();
$loginUserId = $user['id'];
/* Proceed Safely to Model for Storage of User Login */
$logged = $userModel->login($loginUserId, $loginUserIp, $loginDateTime);
$contract->term('userLogged', $logged)->boolean()->equals(TRUE)->metOrThrow();
} catch (Contract_Exception $e) {
/* Collect error messages from contract exception */
$messages = array();
switch ($e->term) {
case 'userEmail':
$messages[] = 'Please enter an email address.';
break;
case 'userPass':
$messages[] = 'Please enter a password.';
break;
case 'userIp':
$messages[] = 'Please enter a valid ip address.';
break;
case 'dateTime':
$messages[] = 'Please enter a valid date time.';
break;
case 'user':
$messages[] = 'Please enter a valid user.';
break;
case 'userLogged':
$messages[] = 'Sorry. You could not be logged in.';
break;
default:
$messages[] = 'We do not get it either!';
break;
}
}
}
}
开发者ID:jeisc,项目名称:PHP-Contract,代码行数:50,代码来源:Controller.php
示例16: makeChartSqlQuery
protected static function makeChartSqlQuery()
{
$quote = DatabaseCompatibilityUtil::getQuote();
$where = null;
$selectDistinct = false;
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Contract');
Contract::resolveReadPermissionsOptimizationToSqlQuery(Yii::app()->user->userModel, $joinTablesAdapter, $where, $selectDistinct);
$selectQueryAdapter = new RedBeanModelSelectQueryAdapter($selectDistinct);
$sumPart = "{$quote}currencyvalue{$quote}.{$quote}value{$quote} ";
$sumPart .= "* {$quote}currencyvalue{$quote}.{$quote}ratetobase{$quote}";
$selectQueryAdapter->addClause('customfield', 'value', 'source');
$selectQueryAdapter->addClauseByQueryString("sum({$sumPart})", 'amount');
$joinTablesAdapter->addFromTableAndGetAliasName('customfield', 'source_customfield_id', 'contract');
$joinTablesAdapter->addFromTableAndGetAliasName('currencyvalue', 'amount_currencyvalue_id', 'contract');
$groupBy = "{$quote}customfield{$quote}.{$quote}value{$quote}";
$sql = SQLQueryUtil::makeQuery('contract', $selectQueryAdapter, $joinTablesAdapter, null, null, $where, null, $groupBy);
return $sql;
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:18,代码来源:ContractsBySourceChartDataProvider.php
示例17: showForContract
/**
* Print the HTML array of suppliers for this contract
*
* @since version 0.84
*
* @param $contract Contract object
*
* @return Nothing (HTML display)
**/
static function showForContract(Contract $contract)
{
global $DB, $CFG_GLPI;
$instID = $contract->fields['id'];
if (!$contract->can($instID, 'r') || !Session::haveRight("contact_enterprise", "r")) {
return false;
}
$canedit = $contract->can($instID, 'w');
$rand = mt_rand();
$query = "SELECT `glpi_contracts_suppliers`.`id`,\n `glpi_suppliers`.`id` AS entID,\n `glpi_suppliers`.`name` AS name,\n `glpi_suppliers`.`website` AS website,\n `glpi_suppliers`.`phonenumber` AS phone,\n `glpi_suppliers`.`suppliertypes_id` AS type,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_suppliers`,\n `glpi_suppliers`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_suppliers`.`entities_id`)\n WHERE `glpi_contracts_suppliers`.`contracts_id` = '{$instID}'\n AND `glpi_contracts_suppliers`.`suppliers_id`=`glpi_suppliers`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_suppliers", '', '', true) . "\n ORDER BY `glpi_entities`.`completename`, `name`";
$result = $DB->query($query);
$suppliers = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$suppliers[$data['id']] = $data;
$used[$data['entID']] = $data['entID'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a supplier') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
Supplier::dropdown(array('used' => $used, 'entity' => $contract->fields["entities_id"], 'entity_sons' => $contract->fields["is_recursive"]));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Supplier') . "</th>";
echo "<th>" . __('Entity') . "</th>";
echo "<th>" . __('Third party type') . "</th>";
echo "<th>" . __('Phone') . "</th>";
echo "<th>" . __('Website') . "</th>";
echo "</tr>";
$used = array();
foreach ($suppliers as $data) {
$ID = $data['id'];
$website = $data['website'];
if (!empty($website)) {
if (!preg_match("?https*://?", $website)) {
$website = "http://" . $website;
}
$website = "<a target=_blank href='{$website}'>" . $data['website'] . "</a>";
}
$entID = $data['entID'];
$entity = $data['entity'];
$used[$entID] = $entID;
$entname = Dropdown::getDropdownName("glpi_suppliers", $entID);
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
}
echo "<td class='center'>";
if ($_SESSION["glpiis_ids_visible"] || empty($entname)) {
$entname = sprintf(__('%1$s (%2$s)'), $entname, $entID);
}
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id={$entID}'>" . $entname;
echo "</a></td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $entity) . "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_suppliertypes", $data['type']) . "</td>";
echo "<td class='center'>" . $data['phone'] . "</td>";
echo "<td class='center'>" . $website . "</td>";
echo "</tr>";
}
echo "</table>";
if ($canedit && $number) {
$paramsma['ontop'] = false;
Html::showMassiveActions(__CLASS__, $paramsma);
Html::closeForm();
}
echo "</div>";
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:contract_supplier.class.php
示例18: array
$html .= "</td>";
$html .= '<td align=center><a href="' . edkuri::build(array(array('ctr_id', $ctrID, false), array('op', 'edit', false), array('sop', "del_{$type}", false), array('id', $contracttarget->getID(), false))) . '">delete</a></td></tr>';
}
if ($c < 30) {
$html .= '<form id=add_target name=add_target method=post action="' . edkuri::build(array(array('ctr_id', $ctrID, false), array('op', 'edit', false))) . '">';
$html .= "<tr><td></td></tr>";
$html .= "<tr><td><input type=text id=add_name name=add_name size=30 maxlength=30></td><td align=center><input type=radio name=add_type id=add_type value=0 checked></td><td align=center><input type=radio name=add_type id=add_type value=1></td><td align=center><input type=radio name=add_type id=add_type value=2></td><td align=center><input type=radio name=add_type id=add_type value=3></td><td align=center><input type=submit id=submit name=submit value=Add></td></tr>";
}
$html .= "</table>";
$html .= "</form>";
}
}
// add
if (edkURI::getArg('op') == "add") {
if ($_POST['detail_submit']) {
$contract = new Contract();
$contract->add($_POST['ctr_name'], $_POST['ctr_started'], $_POST['ctr_ended'], $_POST['ctr_comment']);
header("Location: " . htmlspecialchars_decode(edkuri::build(array(array('ctr_id', $contract->getID(), false), array('op', 'edit', false)))));
}
$page->setTitle("Administration - Add Campaign");
$html .= "<div class=block-header2>Details</div>";
$html .= '<form id=detail_edit name=detail_edit method=post action="' . edkuri::build(array(array('ctr_id', $ctrID, false), array('op', 'add', false))) . '">';
$html .= "<table class=kb-table width=98%>";
$html .= "<tr><td width=80><b>Name:</b></td><td><input type=text name=ctr_name id=ctr_name size=40 maxlength=40></td></tr>";
$html .= "<tr><td width=80><b>Start date:</b></td><td><input type=text name=ctr_started id=ctr_started size=10 maxlength=10 value=\"" . kbdate("Y-m-d") . "\"> (yyyy-mm-dd)</td></tr>";
$html .= "<tr><td width-80><b>End date:</b></td><td><input type=text name=ctr_ended id=ctr_ended size=10 maxlength=10> (yyyy-mm-dd or blank)</td></tr>";
$html .= "<tr><td><b>Comment:</b></td><td><input type='text' name='ctr_comment' size='100'/></td></tr>";
$html .= "<tr><td></td></tr>";
$html .= "<tr><td></td><td><input type=submit name=detail_submit value=\"Save\"></td></tr>";
$html .= "</table>";
$html .= "</form>";
开发者ID:biow0lf,项目名称:evedev-kb,代码行数:31,代码来源:admin_cc.php
示例19: showForContract
/**
* Print the contract costs
*
* @param $contract Contract object
* @param $withtemplate boolean Template or basic item (default '')
*
* @return Nothing (call to classes members)
**/
static function showForContract(Contract $contract, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $contract->fields['id'];
if (!$contract->getFromDB($ID) || !$contract->can($ID, READ)) {
return false;
}
$canedit = $contract->can($ID, UPDATE);
echo "<div class='center'>";
$query = "SELECT *\n FROM `glpi_contractcosts`\n WHERE `contracts_id` = '{$ID}'\n ORDER BY `begin_date`";
$rand = mt_rand();
if ($canedit) {
echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
echo "<script type='text/javascript' >\n";
echo "function viewAddCost" . $ID . "_{$rand}() {\n";
$params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $ID, 'id' => -1);
Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
echo __('Add a new cost') . "</a></div>\n";
}
if ($result = $DB->query($query)) {
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='5'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>";
if ($DB->numrows($result)) {
echo "<tr><th>" . __('Name') . "</th>";
echo "<th>" . __('Begin date') . "</th>";
echo "<th>" . __('End date') . "</th>";
echo "<th>" . __('Budget') . "</th>";
echo "<th>" . __('Cost') . "</th>";
echo "</tr>";
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Contract::getTypeName(1), $contract->getName()));
$total = 0;
while ($data = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data['contracts_id'] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
$name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
echo "<td>";
printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
if ($canedit) {
echo "\n<script type='text/javascript' >\n";
echo "function viewEditCost" . $data['contracts_id'] . "_" . $data["id"] . "_{$rand}() {\n";
$params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $data["contracts_id"], 'id' => $data["id"]);
Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
}
echo "</td>";
echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
echo "<td>" . Html::convDate($data['end_date']) . "</td>";
echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
echo "<td class='numeric'>" . Html::formatNumber($data['cost']) . "</td>";
$total += $data['cost'];
echo "</tr>";
Session::addToNavigateListItems(__CLASS__, $data['id']);
}
echo "<tr class='b noHover'><td colspan='3'> </td>";
echo "<td class='right'>" . __('Total cost') . '</td>';
echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>';
} else {
echo "<tr><th colspan='5'>" . __('No item found') . "</th></tr>";
}
echo "</table>";
}
echo "</div><br>";
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:74,代码来源:contractcost.class.php
示例20: testImportWithRateAndCurrencyCodeSpecified
/**
* There is a special way you can import rateToBase and currencyCode for an amount attribute.
* if the column data is formatted like: $54.67__1.2__USD then it will split the column and properly
* handle rate and currency code. Eventually this will be exposed in the user interface
*/
public function testImportWithRateAndCurrencyCodeSpecified()
{
Yii::app()->user->userModel = User::getByUsername('super');
$account = AccountTestHelper::createAccountByNameForOwner('Account', Yii::app()->user->userModel);
$accountId = $account->id;
$contracts = Contract::getAll();
$this->assertEquals(0, count($contracts));
$import = new Import();
$serializedData['importRulesType'] = 'Contracts';
$serializedData['firstRowIsHeaderRow'] = true;
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importTestIncludingRateAndCurrencyCode.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contracts.tests.unit.files'));
//update the ids of the account column to match the parent account.
ZurmoRedBean::exec("update " . $import->getTempTableName() . " set column_3 = " . $account->id . " where id != 1 limit 4");
$this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
// includes header rows.
$currency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
$mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('name'), 'column_1' => ImportMappingUtil::makeDateColumnMappingData('closeDate'), 'column_2' => ImportMappingUtil::makeIntegerColumnMappingData('description'), 'column_3' => ImportMappingUtil::makeHasOneColumnMappingData('account'), 'column_4' => ImportMappingUtil::makeDropDownColumnMappingData('stage'), 'column_5' => ImportMappingUtil::makeDropDownColumnMappingData('source'), 'column_6' => ImportMappingUtil::makeCurrencyColumnMappingData('amount', $currency));
$importRules = ImportRulesUtil::makeImportRulesByType('Contracts');
$page = 0;
$config = array('pagination' => array('pageSize' => 50));
//This way all rows are processed.
$dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
$dataProvider->getPagination()->setCurrentPage($page);
$importResultsUtil = new ImportResultsUtil($import);
$messageLogger = new ImportMessageLogger();
ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
$importResultsUtil->processStatusAndMessagesForEachRow();
//Confirm that 3 models where created.
$contracts = Contract::getAll();
$this->assertEquals(3, count($contracts));
$contracts = Contract::getByName('opp1');
$this->assertEquals(1, count($contracts[0]));
$this->assertEquals('opp1', $contracts[0]->name);
$this->assertEquals('1980-06-03', $contracts[0]->closeDate);
$this->assertEquals(10, $contracts[0]->probability);
$this->assertEquals('desc1', $contracts[0]->description);
$this->assertTrue($contracts[0]->account->isSame($account));
$this->assertEquals('Prospecting', $contracts[0]->stage->value);
$this->assertEquals('Self-Generated', $contracts[0]->source->value);
$this->assertEquals(500, $contracts[0]->amount->value);
$this->assertEquals(1, $contracts[0]->amount->rateToBase);
$this->assertEquals('USD', $contracts[0]->amount->currency->code);
$contracts = Contract::getByName('opp2');
$this->assertEquals(1, count($contracts[0]));
$this->assertEquals('opp2', $contracts[0]->name);
$this->assertEquals('1980-06-04', $contracts[0]->closeDate);
$this->assertEquals(25, $contracts[0]->probability);
$this->assertEquals('desc2', $contracts[0]->description);
$this->assertTrue($contracts[0]->account->isSame($account));
$this->assertEquals('Qualification', $contracts[0]->stage->value);
$this->assertEquals('Inbound Call', $contracts[0]->source->value);
$this->assertEquals(501, $contracts[0]->amount->value);
// $this->assertEquals(2.7, $contracts[0]->amount->rateToBase);
$this->assertEquals('GBP', $contracts[0]->amount->currency->code);
$contracts = Contract::getByName('opp3');
$this->assertEquals(1, count($contracts[0]));
$this->assertEquals('opp3', $contracts[0]->name);
$this->assertEquals('1980-06-05', $contracts[0]->closeDate);
$this->assertEquals(50, $contracts[0]
|
请发表评论