function toString($value) { version_assert and assertTrue(count(func_get_args()) == 1); version_assert and assertTrue(count(debug_backtrace()) < 1024, "Infinite recursion detected"); if (is_object($value)) { $value = _toCorrectClass($value); } if (is_object($value) && hasMember($value, 'toString')) { return $value->toString(); } else { if (is_object($value) && hasMember($value, 'toRaw')) { return toString($value->toRaw()); } else { if (is_array($value)) { $intermediate = array(); foreach ($value as $v) { $intermediate[] = toString($v); } return '[' . implode(', ', $intermediate) . ']'; } else { return (string) $value; } } } }
public function run($method, $para = array(), $return = "", $charset = "utf-8") { $result = ""; if (isset($this->methods[$method])) { $result = call_user_func_array($this->methods[$method], $para); } if (empty($charset)) { $charset = "utf-8"; } switch ($return) { case "j": case "json": $result = toJson($result, $charset); break; case "x": case "xml": $result = '<?xml version="1.0" encoding="' . $charset . '"?>' . "\n<mystep>\n" . toXML($result) . "</mystep>"; header('Content-Type: application/xml; charset=' . $charset); break; case "s": case "string": $result = toString($result); break; default: break; } return $result; }
/** * Returns the List of Calls paginated for Bootstrap Table depending of the current User * * @Route("/list", name="_admin_calls_list") * @Security("is_granted('ROLE_EMPLOYEE')") * @Template() */ public function paginatedListAction() { $request = $this->get('request'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? return new Response("<b>Not an ajax call!!!" . "</b>"); } $logger = $this->get('logger'); try { $limit = $request->get('limit'); $offset = $request->get('offset'); $order = $request->get('order'); $search = $request->get('search'); $sort = $request->get('sort'); $em = $this->getDoctrine()->getManager(); $usr = $this->get('security.context')->getToken()->getUser(); $isAdmin = $this->get('security.context')->isGranted('ROLE_ADMIN'); $paginator = $em->getRepository('Tech506CallServiceBundle:Call')->getPageWithFilterForUser($offset, $limit, $search, $sort, $order, $isAdmin, $usr); $results = $this->getResults($paginator); return new Response(json_encode(array('total' => count($paginator), 'rows' => $results))); } catch (Exception $e) { $info = toString($e); $logger->err('User::getUsersList [' . $info . "]"); return new Response(json_encode(array('error' => true, 'message' => $info))); } }
/** * Runs the example. * @param AdWordsUser $user the user to run the example with */ function GetBudgetSuggestionExample(AdWordsUser $user) { // Get the service, which loads the required classes. $budgetSuggestionService = $user->GetService('BudgetSuggestionService', ADWORDS_VERSION); $criteria = array(); // Create selector. $selector = new BudgetSuggestionSelector(); // Criterion - Travel Agency product/service. // See GetProductServicesExample.php for an example of how to get valid // product/service settings. $productService = new ProductService(); $productService->text = "Travel Agency"; $productService->locale = "en_US"; $criteria[] = $productService; // Criterion - English language. // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/languagecodes $language = new Language(); $language->id = 1000; $criteria[] = $language; // Criterion - Mountain View, California location. // The ID can be found in the documentation: // https://developers.google.com/adwords/api/docs/appendix/geotargeting // https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions $location = new Location(); $location->id = 1014044; $criteria[] = $location; $selector->criteria = $criteria; $budgetSuggestion = $budgetSuggestionService->get($selector); printf("Budget suggestion for criteria is:\n" . " SuggestedBudget=%s\n" . " Min/MaxBudget=%s/%s\n" . " Min/MaxCpc=%s/%s\n" . " CPM=%s\n" . " CPC=%s\n" . " Impressions=%d\n", toString($budgetSuggestion->suggestedBudget), toString($budgetSuggestion->minBudget), toString($budgetSuggestion->maxBudget), toString($budgetSuggestion->minCpc), toString($budgetSuggestion->maxCpc), toString($budgetSuggestion->cpm), toString($budgetSuggestion->cpc), $budgetSuggestion->impressions); }
function __toString($node, &$result) { switch ($node->nodeType) { case XML_COMMENT_NODE: $result .= '<!-- ' . $node->nodeValue . ' -->'; break; case XML_TEXT_NODE: $result .= '<p>' . $node->nodeValue . '</p>'; break; case XML_CDATASection: break; default: $result .= '<' . $node->nodeName; if ($node->hasAttributes()) { foreach ($node->attributes as $key => $val) { $result .= ' ' . $key . '="' . $val . '"'; } } if ($node->hasChildNodes()) { $result .= '>'; foreach ($node->childNodes as $child) { toString($child, $result); } $result .= '</' . $node->nodeName . '>'; } else { $result .= '/>'; } } }
function afficher() { if ($score = afficherBDD() and isset($score)) { toString($score); } else { echo "erreur de la base"; } }
function gen_client_id() { $uuid = Uuid::uuid4(); $cid = $uuid . toString(); // Put it in a cookie to use in the future setcookie('gacid', $cid, time() + 60 * 60 * 24 * 365 * 2, '/', '.prodatakey.com'); return $cid; }
/** * Return string representation (which will also be a valid CLI command) of this command. * * @return void */ public function __toString() { $str = $this->getName() . ' '; foreach ($_options as $option) { $str .= $_option . toString() . next($_options) ? ' ' : ''; } foreach ($_resources as $resource) { $str .= $_resource; } }
function http_build_query(&$data) { $keys = array_keys($data); $string = ''; $f = true; foreach ($keys as $key) { if ($f) { $string .= $key . '=' . toString($data[$key]); $f = false; } else { $string .= '&' . $key . '=' . toString($data[$key]); } } return $string; }
public function sendHtmlAction() { $sendTo = @$_POST['sendTo'] ?: ''; $from = @$_POST['from'] ?: ''; $url = @$_POST['url'] ?: ''; $content = @$_POST['content'] ?: ''; $imageEnabled = isset($_POST['imageEnabled']) && $_POST['imageEnabled'] === '1' ? true : false; d($_POST); try { $this->result['result'] = Service::sendHtmlToKindle($sendTo, $from, $url, $content, $imageEnabled); } catch (Exception $e) { d($e); $this->result['message'] = toString($e); } $this->render($this->result); }
function string($n) { if (js()) { if (typeof($n) === "number") { return Number($n) . toString(); } else { if (typeof($n) === "undefined") { return ""; } else { return $n . toString(); } } } else { return "" . $n; } }
/** * A convenience for throwing a PreconditionException. */ function con($assertation, $location, $msg, ...$variables) { if ($assertation === true) { return; } $first = true; $msg_var = ""; foreach ($variables as $var) { if ($first) { $msg_var .= toString($var); } else { $msg_var .= ", " . toString($var); } $first = false; } throw new Exception($location . " - " . $msg . $msg_var); }
function getAndCleanData($dataWindPrev) { $url = $dataWindPrev->getUrl(); $step = 0; $start_time = microtime(true); // top chrono try { $result = $this->getDataURL($url); $step = 1; $result = $this->analyseData($result, $url); $step = 2; $result = $this->transformData($result); $step = 3; } catch (Exception $e) { $result = toString($e); } $chrono = microtime(true) - $start_time; return array($step, $result, $chrono); }
/** * Replaces all old string within the expression with new strings. * * @param String|\Tbm\Peval\Types\String $expression * The string being processed. * @param String|\Tbm\Peval\Types\String $oldString * The string to replace. * @param String|\Tbm\Peval\Types\String $newString * The string to replace the old string with. * * @return mixed The new expression with all of the old strings replaced with new * strings. */ public function replaceAll(string $expression, string $oldString, string $newString) { $replacedExpression = $expression; if ($replacedExpression != null) { $charCtr = 0; $oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr); while ($oldStringIndex > -1) { // Remove the old string from the expression. $buffer = new StringBuffer($replacedExpression->subString(0, oldStringIndex)->getValue() . $replacedExpression->substring($oldStringIndex + $oldString . length())); // Insert the new string into the expression. $buffer . insert($oldStringIndex, $newString); $replacedExpression = buffer . toString(); $charCtr = $oldStringIndex + $newString->length(); // Determine if we need to continue to search. if ($charCtr < $replacedExpression->length()) { $oldStringIndex = $replacedExpression->indexOf($oldString, $charCtr); } else { $oldStringIndex = -1; } } } return $replacedExpression; }
/** * */ function __construct($host, $username, $passwd, $dbname) { $this->con = @new mysqli($host, $username, $passwd, $dbname); if ($this->con->connect_error) { $msg = toString($this->con->connect_error); //weird exception makes the message blank, if encoding errors occur. throw new Exception(strip_to_ascii($msg)); } $this->con->set_charset("utf8"); }
function dayString($jd, $next, $flag) { //only ever calls 0,2 or 0,3 // returns a string in the form DDMMMYYYY[ next] to display prev/next rise/set // flag=2 for DD MMM, 3 for DD MM YYYY, 4 for DDMMYYYY next/prev if ($jd < 900000 || $jd > 2817000) { $output = "error"; } else { $z = floor($jd + 0.5); $f = $jd + 0.5 - $z; if ($z < 2299161) { $A = $z; } else { $alpha = floor(($z - 1867216.25) / 36524.25); $A = $z + 1 + $alpha - floor($alpha / 4); } $B = $A + 1524; $C = floor(($B - 122.1) / 365.25); $D = floor(365.25 * $C); $E = floor(($B - $D) / 30.6001); $day = $B - $D - floor(30.6001 * $E) + $f; $month = $E < 14 ? $E - 1 : $E - 13; $year = $month > 2 ? $C - 4716 : $C - 4715; if ($flag == 2) { $output = $this->zeroPad($day, 2) . " " . $this->monthList($month); } if ($flag == 3) { $output = $this->zeroPad($day, 2) . $this->monthList($month) . year . toString(); } if ($flag == 4) { $output = $this->zeroPad($day, 2) . $this->monthList($month) . year . toString() . ($next ? " next" : " prev"); } } return $output; }
/** * @Route("/details/save", name="_admin_services_rows_save") * @Security("is_granted('ROLE_ADMIN')") * @Template() */ public function saveServiceRowsAction() { $request = $this->get('request'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? return new Response("<b>Not an ajax call!!!" . "</b>"); } $logger = $this->get('logger'); try { $em = $this->getDoctrine()->getManager(); $serviceId = $request->get('serviceId'); $technicianService = $em->getRepository('Tech506CallServiceBundle:TechnicianService')->find($serviceId); $oldDetails = $technicianService->getDetails(); $data = $request->get('data'); /* 0: detail.id 1: detail.productSaleType.product.id 2: detail.productSaleType.id 3: detail.fullPrice 4: detail.sellerWin 5: detail.technicianWin 6: detail.transportationCost 7: detail.utility 8: detail.observations */ $rows = explode("<>", $data); $updatedRows = array(); foreach ($rows as $row) { if ($row != "") { $rowData = explode("/", $row); /*$logger->info("--------------------------------------------"); $logger->info("row: " . $row); $logger->info("detail id: " . $rowData[0]); $logger->info("product id: " . $rowData[1]); $logger->info("produc sale type id: " . $rowData[2]); $logger->info("full price: " . $rowData[3]); $logger->info("seller: " . $rowData[4]); $logger->info("technician: " . $rowData[5]); $logger->info("transportation: " . $rowData[6]); $logger->info("utility: " . $rowData[7]); $logger->info("observations: " . $rowData[8]);*/ $serviceDetail = new ServiceDetail(); if ($rowData[0] != 0) { //Must update the Row array_push($updatedRows, $rowData[0]); $serviceDetail = $em->getRepository('Tech506CallServiceBundle:ServiceDetail')->find($rowData[0]); } else { $serviceDetail->setTechnicianService($technicianService); $saleType = $em->getRepository('Tech506CallServiceBundle:ProductSaleType')->find($rowData[2]); $serviceDetail->setProductSaleType($saleType); } $serviceDetail->setFullPrice($rowData[3]); $serviceDetail->setSellerWin($rowData[4]); $serviceDetail->setTechnicianWin($rowData[5]); $serviceDetail->setTransportationCost($rowData[6]); $serviceDetail->setUtility($rowData[7]); $serviceDetail->setObservations($rowData[8]); $em->persist($serviceDetail); //$serviceDetail->setQuantity(); } } $detailsToRemove = array(); foreach ($oldDetails as $detail) { if (!in_array($detail->getId(), $updatedRows)) { array_push($detailsToRemove, $detail); $em->remove($detail); } } foreach ($detailsToRemove as $detail) { $technicianService->removeDetail($detail); } $em->persist($technicianService); $em->flush(); $translator = $this->get('translator'); return new Response(json_encode(array('error' => false, 'msg' => $translator->trans('information.save.success')))); } catch (Exception $e) { $info = toString($e); $logger->err('Services::saveServiceRowsAction [' . $info . "]"); return new Response(json_encode(array('error' => true, 'message' => $info))); } }
function debug($var) { $traces = debug_backtrace(); $places = array(); foreach ($traces as $trace) { $places[] = str_replace(array(DIR_ROOT, '\\'), array('', '/'), $trace['file'] . ':' . $trace['line']); } $place = str_replace(':', ', line ', array_shift($places)); $trace = debug_backtrace(); $trace = array_shift($trace); $place = str_replace(array(DIR_ROOT, '\\'), array('', '/'), $trace['file'] . ', line ' . $trace['line']); $vars = array(); foreach (func_get_args() as $var) { $vars[] = nl2br(toString($var)); } $places = join(" ", $places); print system_window("<u>DEBUG</u> at <span title=\"{$places}\">{$place}</span>", $vars, '#CDE'); return true; }
function &xmlFileToArray($fileName, $includeTopTag = false, $lowerCaseTags = true) { // Definition file not found if (!file_exists($fileName)) { // Error $false = false; return $false; } $p = xml_parser_create(); xml_parse_into_struct($p, toString($fileName), $vals, $index); xml_parser_free($p); $xml = array(); $levels = array(); $multipleData = array(); $prevTag = ""; $currTag = ""; $topTag = false; foreach ($vals as $val) { // Open tag if ($val["type"] == "open") { if (!_xmlFileToArrayOpen($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml)) { continue; } } else { if ($val["type"] == "close") { if (!_xmlFileToArrayClose($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml)) { continue; } } else { if ($val["type"] == "complete" && isset($val["value"])) { $loc =& $xml; foreach ($levels as $level) { $temp =& $loc[str_replace(":arr#", "", $level)]; $loc =& $temp; } $tag = $val["tag"]; if ($lowerCaseTags) { $tag = strtolower($val["tag"]); } $loc[$tag] = str_replace("\\n", "\n", $val["value"]); } else { if ($val["type"] == "complete") { _xmlFileToArrayOpen($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml); _xmlFileToArrayClose($topTag, $includeTopTag, $val, $lowerCaseTags, $levels, $prevTag, $multipleData, $xml); } } } } } return $xml; }
/** * Save or Update an Association * * @Route("/patients/association/save", name="_patients_save_association") * @Security("is_granted('ROLE_EMPLOYEE')") * @Template() */ public function saveAssociationAction() { $logger = $this->get('logger'); if ($this->get('request')->isXmlHttpRequest()) { try { //Get parameters $request = $this->get('request'); $id = $request->get('id'); $association = $request->get('association'); $translator = $this->get("translator"); if (isset($id) && isset($association)) { $em = $this->getDoctrine()->getManager(); $patient = $em->getRepository("TecnotekAsiloBundle:Patient")->find($id); if (isset($patient)) { switch ($association) { case "pention": $associationId = $request->get('associationId'); if (isset($associationId)) { $action = $request->get("action"); switch ($action) { case "save": $patientPention = new PatientPention(); if ($associationId != 0) { $patientPention = $em->getRepository("TecnotekAsiloBundle:PatientPention")->find($associationId); } $patientPention->setPatient($patient); $pentionId = $request->get("pentionId"); $pention = $em->getRepository("TecnotekAsiloBundle:Pention")->find($pentionId); if (isset($pention)) { $patientPention->setPention($pention); $detail = $request->get("name"); $detail = trim($detail) == "" ? $pention->getName() : $detail; $patientPention->setDetail($detail); $patientPention->setAmount($request->get("amount")); $em->persist($patientPention); $em->flush(); return new Response(json_encode(array('id' => $patientPention->getId(), 'name' => $detail, 'amount' => $patientPention->getAmount(), 'error' => false, 'msg' => $translator->trans('add.pention.success')))); } else { return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters Pention"))); } break; case "delete": $patientPention = $em->getRepository("TecnotekAsiloBundle:PatientPention")->find($associationId); $em->remove($patientPention); $em->flush(); return new Response(json_encode(array('error' => false, 'msg' => ""))); break; default: return new Response(json_encode(array('error' => true, 'msg' => "Accion desconocida"))); } } else { return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters"))); } break; default: break; } } else { return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters Patient"))); } } else { return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters Id or Association"))); } } catch (Exception $e) { $info = toString($e); $logger->err('Sport::saveSportAction [' . $info . "]"); return new Response(json_encode(array('error' => true, 'msg' => $info))); } } else { return new Response("<b>Not an ajax call!!!" . "</b>"); } }
/** * Delete an Entity of the Catalog * * @Route("/users/delete", name="_admin_users_delete") * @Security("is_granted('ROLE_EMPLOYEE')") * @Template() */ public function deleteAction() { $logger = $this->get('logger'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? return new Response("<b>Not an ajax call!!!" . "</b>"); } try { //Get parameters $request = $this->get('request'); $id = $request->get('id'); $entity = $request->get('entity'); $translator = $this->get("translator"); if (isset($id)) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('TecnotekAsiloBundle:User')->find($id); if (isset($user)) { $em->remove($user); $em->flush(); return new Response(json_encode(array('error' => false, 'msg' => $translator->trans('catalog.delete.success')))); } else { return new Response(json_encode(array('error' => true, 'msg' => $translator->trans('validation.not.found')))); } } else { return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters"))); } } catch (Exception $e) { $info = toString($e); $logger->err('Catalog::deleteAction [' . $info . "]"); return new Response(json_encode(array('error' => true, 'msg' => $info))); } }
/** * Change the current user password * * @Route("/account/updatePassword", name="_admin_account_update_password") * @Security("is_granted('ROLE_EMPLOYEE')") * @Template() */ public function updatePasswordAction() { $logger = $this->get('logger'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? return new Response("<b>Not an ajax call!!!" . "</b>"); } try { //Get parameters $request = $this->get('request'); $id = $request->get('id'); $current = $request->get('current'); $new = $request->get('new'); $translator = $this->get("translator"); if (isset($id) && isset($current) && isset($new)) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('Tech506SecurityBundle:User')->find($id); if (isset($user)) { $encoder = $this->container->get('security.encoder_factory')->getEncoder($user); $currentEncoded = $encoder->encodePassword($current, $user->getSalt()); if ($currentEncoded == $user->getPassword()) { $user->setPassword($encoder->encodePassword($new, $user->getSalt())); $em->persist($user); $em->flush(); return new Response(json_encode(array('error' => false, 'msg' => $translator->trans('account.update.password.success')))); } else { return new Response(json_encode(array('error' => true, 'msg' => $translator->trans('current.password.error')))); } } else { return new Response(json_encode(array('error' => true, 'msg' => $translator->trans('validation.not.found')))); } } else { return new Response(json_encode(array('error' => true, 'msg' => "Missing Parameters"))); } } catch (Exception $e) { $info = toString($e); $logger->err('Catalog::updatePasswordAction [' . $info . "]"); return new Response(json_encode(array('error' => true, 'msg' => $info))); } }
/** * @Route("/clients/save", name="_admin_clients_save") * @Security("is_granted('ROLE_SELLER')") * @Template() */ public function saveClientAction() { $request = $this->get('request'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? return new Response("<b>Not an ajax call!!!" . "</b>"); } $logger = $this->get('logger'); try { $id = $request->get('id'); $fullName = $request->get('fullName'); $address = $request->get('address'); $phone = $request->get('phone'); $email = $request->get('email'); $cellPhone = $request->get('cellPhone'); $extraInformation = $request->get('extraInformation'); $em = $this->getDoctrine()->getManager(); $client = new Client(); if ($id != 0) { $client = $em->getRepository('Tech506CallServiceBundle:Client')->find($id); } else { $client = $em->getRepository('Tech506CallServiceBundle:Client')->findClient($phone, $cellPhone, $email); if (!isset($client)) { $client = new Client(); } } $client->setAddress($address); $client->setEmail($email); $client->setFullName($fullName); $client->setCellPhone($cellPhone); $client->setPhone($phone); $client->setExtraInformation($extraInformation); $em->persist($client); $em->flush(); return new Response(json_encode(array('error' => false, 'msg' => "Cliente guardado correctamente", 'id' => $client->getId()))); } catch (Exception $e) { $info = toString($e); $logger->err('Seller::getUsersList [' . $info . "]"); return new Response(json_encode(array('error' => true, 'message' => $info))); } }
// ContenidoLogica $cont = null; // String $tipocont = null; try { // String $id_cont = request . getParameter("id"); // int $id = 0; try { $id = Integer . parseInt($id_cont); } catch (NumberFormatException $ex) { } $cont = ContenidoLogica . Buscar(id); $tipocont = cont . getTipo() . toString() . toLowerCase(); } catch (NullPointerException $e) { } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Ver Capitulo</title> <!-- <link rel='stylesheet' type='text/css' href="../Scripts/stylesWeb2.css"> --> <link rel='stylesheet' type='text/css' href="../Scripts/jquery-ui.min.css"> <script type="text/javascript" src="../Scripts/jquery-2.0.0.min.js" ></script> <script type="text/javascript" src="../Scripts/jquery.validate.min.js" ></script> <script type="text/javascript" src="../Scripts/jquery-ui.min.js" ></script> <script type="text/javascript" src="../Scripts/ajaxRequestScript.js" ></script> <script type="text/javascript" src="../Scripts/ContenidoBindings.js"></script> <script type="text/javascript">
/** * @test */ public function shouldConvertObjectToString() { //given $obj = new stdClass(); $obj->name = 'John'; $obj->id = 1; //when $toString = toString($obj); //then /** @noinspection HtmlUnknownTag */ $this->assertEquals('stdClass {<name> => "John", <id> => 1}', $toString); }
/** * {@inheritDoc} */ public function getFactoryArchitecture() { $result = ''; // ?:B->SIGMOID->4:B->SIGMOID->? for ($currentLayer = 0; $currentLayer < $this->getLayerCount(); ++$currentLayer) { // need arrow from prvious levels? if ($currentLayer > 0) { $result .= "->"; } // handle activation function if ($currentLayer > 0 && $this->getActivation($currentLayer) != null) { $activationFunction = $this->getActivation($currentLayer); $result .= $activationFunction->getFactoryCode(); $result .= "->"; } $result .= $this . getLayerNeuronCount($currentLayer); if ($this->isLayerBiased($currentLayer)) { $result->append(":B"); } } return $result . toString(); }
/** * Returns the List of Calls paginated for Bootstrap Table depending of the current User * * @Route("/get-pending", name="_admin_commisions_get_pending") * @Security("is_granted('ROLE_EMPLOYEE')") * @Template() */ public function getServicesCommisionPendingAction() { $request = $this->get('request'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? //return new Response("<b>Not an ajax call!!!" . "</b>"); } $logger = $this->get('logger'); try { $em = $this->getDoctrine()->getManager(); $usr = $this->get('security.context')->getToken()->getUser(); $isAdmin = $this->get('security.context')->isGranted('ROLE_ADMIN'); $request = $this->get('request'); $employeeType = $request->get('employeeType'); $id = $request->get('id'); $services = $em->getRepository('Tech506CallServiceBundle:TechnicianService')->getPendingOfApplyCommision($employeeType, $id); $servicesArray = array(); foreach ($services as $service) { $seller = $service->getSeller(); $technician = $service->getTechnician()->getUser(); // ($id == 0 || $id == $seller->getId()) if (array_key_exists($seller->getId(), $servicesArray)) { $userCommisionDetail = $servicesArray[$seller->getId()]; $userCommisionDetail->includeService($service); if ($seller->getId() != $technician->getId()) { if (array_key_exists($technician->getId(), $servicesArray)) { $userCommisionDetail = $servicesArray[$technician->getId()]; $userCommisionDetail->includeService($service); } else { if (($id == 0 || $id == $technician->getId()) && ($employeeType == 0 || $technician->getUserRoleId() == $employeeType)) { $userCommisionDetail = new UserCommisionsDetail(); $userCommisionDetail->setUser($technician); $userCommisionDetail->includeService($service); $servicesArray[$technician->getId()] = $userCommisionDetail; } } } } else { if (array_key_exists($technician->getId(), $servicesArray)) { $userCommisionDetail = $servicesArray[$technician->getId()]; $userCommisionDetail->includeService($service); if ($seller->getId() != $technician->getId()) { if (($id == 0 || $id == $seller->getId()) && ($employeeType == 0 || $seller->getUserRoleId() == $employeeType)) { $userCommisionDetail = new UserCommisionsDetail(); $userCommisionDetail->setUser($seller); $userCommisionDetail->includeService($service); $servicesArray[$seller->getId()] = $userCommisionDetail; } } } else { if (($id == 0 || $id == $seller->getId()) && ($employeeType == 0 || $seller->getUserRoleId() == $employeeType)) { $userCommisionDetail = new UserCommisionsDetail(); $userCommisionDetail->setUser($seller); $userCommisionDetail->includeService($service); $servicesArray[$seller->getId()] = $userCommisionDetail; } if ($seller->getId() != $technician->getId()) { if (($id == 0 || $id == $technician->getId()) && ($employeeType == 0 || $technician->getUserRoleId() == $employeeType)) { $userCommisionDetail = new UserCommisionsDetail(); $userCommisionDetail->setUser($technician); $userCommisionDetail->includeService($service); $servicesArray[$technician->getId()] = $userCommisionDetail; } } } } } $sss = array(); foreach ($servicesArray as $userCommisionDetail) { $user = $userCommisionDetail->getUser(); array_push($sss, array('user' => array('id' => $user->getId(), 'name' => $user->getFullName(), 'email' => $user->getEmail(), 'phone' => $user->getCellPhone()), 'totalForSales' => $userCommisionDetail->getTotalForSales(), 'totalForTechnician' => $userCommisionDetail->getTotalForTechnician(), 'totalForTransportation' => $userCommisionDetail->getTotalForTransportation(), 'services' => $userCommisionDetail->getServices())); } return new Response(json_encode(array('list' => $sss, 'error' => false, 'msg' => ''))); } catch (Exception $e) { $info = toString($e); $logger->err('Liquidations::getServicesCommisionPendingAction [' . $info . "]"); return new Response(json_encode(array('error' => true, 'message' => $info))); } }
/** * Converts a variable to its string value. * ```php * toString(53)); // '53' * toString(true)); // 'true' * toString(false)); // 'false' * toString(null)); // 'null' * toString('Hello World')); // '"Hello World"' * toString([])); // '[]' * toString(new \stdClass)); // '{}' * toString(function(){})); // '[Function]' * toString(Error::of('Ooops'))); // '[Error: Ooops]' * toString(fopen('php://temp', 'r'))); // '[Resource]' * toString(['hi', 'hello', 'yo'])); // '["hi", "hello", "yo"]' * toString([ * 'object' => Stream::of(null), * 'numbers' => [1, 2, 3], * 'message' * ]); // '{object: Stream(Null), numbers: [1, 2, 3], 0: "message"]' * ``` * * @signature * -> String * @param mixed $something * @return string */ function toString() { $toString = function ($something) { switch (type($something)) { case 'String': return "\"{$something}\""; break; case 'Boolean': return $something ? 'true' : 'false'; break; case 'Null': return 'null'; break; case 'Number': return (string) $something; break; case 'List': return '[' . join(', ', map(toString(), $something)) . ']'; break; case 'Error': case 'Stream': return $something->__toString(); case 'Object': case 'Array': return '{' . join(', ', map(function ($pair) { return $pair[0] . ': ' . toString($pair[1]); }, toPairs($something))) . '}'; default: return '[' . type($something) . ']'; } }; return apply(curry($toString), func_get_args()); }
if (preg_match('/.*Test\\.php/', $file) !== 1) { continue; } $filePath = __DIR__ . '/' . $file; if (!file_exists($filePath) && !is_file($filePath)) { continue; } echo PHP_EOL . $file . ' | '; require_once __DIR__ . '/' . $file; $className = explode('.', $file)[0]; $class = new ReflectionClass($className); foreach ($class->getMethods() as $method) { if (preg_match('/test.*/', $method) !== 1) { continue; } if ($filterMethodRegexp && preg_match('#' . $filterMethodRegexp . '#', strtolower($method)) !== 1) { continue; } $reflectionMethod = new ReflectionMethod($class->getName(), $method->name); try { if (!$reflectionMethod->isPublic()) { continue; } $reflectionMethod->invoke($class->newInstance()); } catch (Exception $e) { std(toString($e)); d($e); } } echo PHP_EOL; }
/** * @Route("/users/permissions/save", name="_admin_permissions_save") * @Security("is_granted('ROLE_EMPLOYEE')") * @Template() */ public function savePrivilegesAction() { $logger = $this->get('logger'); if (!$this->get('request')->isXmlHttpRequest()) { // Is the request an ajax one? return new Response("<b>Not an ajax call!!!" . "</b>"); } try { $request = $this->get('request')->request; $userId = $request->get('userId'); $access = $request->get('access'); $type = $request->get('type'); $translator = $this->get("translator"); if (isset($userId) && isset($access)) { $em = $this->getDoctrine()->getEntityManager(); $user = $em->getRepository("TecnotekAsiloBundle:User")->find($userId); if ($type == 1) { // Save Menu Options /*** Set Menu Options ***/ $currentMenuOptions = $user->getMenuOptions(); if ($access == "") { $newMenuOptions = array(); } else { $newMenuOptions = explode(",", $access); } $optionsToRemove = array(); foreach ($currentMenuOptions as $currentMenuOption) { if (!in_array($currentMenuOption->getId(), $newMenuOptions)) { array_push($optionsToRemove, $currentMenuOption); } } foreach ($optionsToRemove as $menuOption) { $user->removeMenuOption($menuOption); } foreach ($newMenuOptions as $newMenuOption) { $found = false; foreach ($currentMenuOptions as $currentMenuOption) { if ($currentMenuOption->getId() == $newMenuOption) { $found = true; break; } } if (!$found) { $newEntityMenuOption = $em->getRepository("TecnotekAsiloBundle:ActionMenu")->find($newMenuOption); $user->addMenuOption($newEntityMenuOption); } } } else { // Save Permissions $currentPermissions = $user->getPermissions(); if ($access == "") { $newPermissions = array(); } else { $newPermissions = explode(",", $access); } $optionsToRemove = array(); foreach ($currentPermissions as $currentPermission) { if (!in_array($currentPermission->getId(), $newPermissions)) { array_push($optionsToRemove, $currentPermission); } } foreach ($optionsToRemove as $permission) { $user->removePermission($permission); } foreach ($newPermissions as $newMenuOption) { $found = false; foreach ($currentPermissions as $currentMenuOption) { if ($currentMenuOption->getId() == $newMenuOption) { $found = true; break; } } if (!$found) { $newEntityMenuOption = $em->getRepository("TecnotekAsiloBundle:Permission")->find($newMenuOption); $user->addPermission($newEntityMenuOption); } } } $em->persist($user); $em->flush(); return new Response(json_encode(array('error' => false))); } else { return new Response(json_encode(array('error' => true, 'message' => $translator->trans("error.paramateres.missing")))); } } catch (Exception $e) { $info = toString($e); $logger->err('SuperAdmin::createEntryAction [' . $info . "]"); return new Response(json_encode(array('error' => true, 'message' => $info))); } }