Exemplo n.º 1
0
 /**
  * Process upload csv file with personalized fields
  */
 public static function postUploadCustomPage($id)
 {
     $app = \Slim\Slim::getInstance();
     $dao = new MessageDAO();
     $item = $dao->fetch($id);
     if (empty($item)) {
         return $app->notFound();
     }
     if (!empty($_FILES['file'])) {
         $groupDAO = new GroupDAO();
         $numbers = $groupDAO->getNumbers($item->getGroupId());
         $contents = file_get_contents($_FILES['file']['tmp_name']);
         $dao->clearCustomFields($item);
         $contents = explode("\n", $contents);
         foreach ($contents as $row) {
             $cells = explode(";", $row);
             $msisdn = array_shift($cells);
             $msisdn = preg_replace('![^0-9]*!', '', $msisdn);
             $dao->addCustomFields($item, $msisdn, $cells);
         }
     }
 }